要實現這個有多種解決方案,比如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