要实现这个有多种解决方案,比如asp, php, 服务器端技术,IFrame等,但本文所记录的仅限于用jQuery和纯htm的解决方案。
<head>
<title></title>
<script src="jquery-1.9.0.js" type="text/javascript"></script>
<script>
$(document).ready(function () {
$("#header").load("header.html");
$("#footer").load("footer.html");
});
</script>
</head>
<body>
<div id="header"></div>
content
<div id="footer"></div>
</body>
</html>
效果图:
参考帖子:http://stackoverflow.com/questions/18712338/common-header-and-footer-include-multiple-html-pages