常用代碼之七:靜態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