常用代码之七:静态htm如何包含header.htm和footer.htm。


要实现这个有多种解决方案,比如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

 

 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM