1、采用js方法
<body>
? ? <div id="div"></div>
? ? <script>
? ? ? ? ? document.getElementById("div").innerHTML = '<object type="text/html" data="index.html" width="100%" height="100%"></object>';
? ? </script>
</body>
<body> ? ?<div id="div"></div> ? ?<script> ? ? ? ? ?$("#div").load("index.html"); ? ?</script> </body>
2、采用apache等服務器,使用include
apache默認不支持SSI,可以通過修改配置文件來使其支持
搜索AddType text/html .shtml的位置,打開以下注釋
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
同時需要找到Options Indexes FollowSymLinks,在其后添上Includes
以上表示支持shtml的include命令,如果還想支持html,則需改為
AddType text/html .shtml .html
AddOutputFilter INCLUDES .shtml .html
使用辦法:
建立A.html文件如下
<!DOCTYPE?html> <html> <head> <meta?charset=utf-8> <title>include</title> </head> <body> ????<!--#include?file="B.html"?--> ?</body> ?</html>
建立B.html文件如下
<div>我是被include包含進來的</div>
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。