让我们假设这是您的主页index.html
:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>HOME PAGE</title>
</head>
<body>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-beta1/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
$("#list").addClass('loader');
$("#list").load('article.php', function() {
$("#list").removeClass('loader');
});
});
</script>
<style>
.loader{
background-image:url(loader.gif);
background-repeat:no-repeat;
background-position:center;
height:10px;
}
</style>
<!--and this is where you want the articles to appear-->
<div id="list"></div>
</body>
</html>
这是你的文章页:article.php
<section>
<article>
<a href="">
<img src="" alt="">
<h1>Heading</h1>
<p>article</p>
</a>
</article>
</section>
而且如果物品是在特定<div>
或<article>
。然后给<div>
或<article>
一个ID,例如<div id="divID" >
或<article id="divID" >
并使用此JavaScript加载代码代替
<script type="text/javascript">
$(function() {
$("#list").addClass('loader');
$("#list").load('article.php #divID', function() {
$("#list").removeClass('loader');
});
});
</script>
您是什么意思的传情?请详细说明。你的问题对我来说很模糊。或者你的意思是你想包括一个文章页面到你的主页? –
我想在我的主页上创建一篇文章的摘录,该文章链接到不同页面上的完整文章。 – Benny
请参考下面的答案,看看它是否适合你 –