html中引入調用另外一個html的方法

html中引入調用另外一個html的方法,嘗試了好幾種,都列出來:
其中第一種是最好的,其餘的方法,能夠嘗試看看,是否是適合你當前項目html

1、div+$(「#page1」).load(「b.html」)
參考代碼:web

<body>
    <div id="page1"></div>
    <div id="page2"></div>
    <script>
          $("#page1").load("page/Page_1.html");
          $("#page2").load("page/Page_2.html");
    </script>
</body>

2、iframe
參考代碼:bootstrap

<head>
</head>
<body>
   <div id="page1">
        <iframe align="center" width="100%" height="170" src="page/Page_1.html"  frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>
   </div>
   <div id="page2">
        <iframe align="center" width="100%" height="170" src="page/Page_2.html"  frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>
   </div>
</body>

3、object引入
參考代碼:markdown

<head>
    <object style="border:0px" type="text/x-scriptlet" data="page/Page_1.html" width=100% height=150>
    </object>
</head>

4、import引入
參考代碼:ui

<head>
    <link rel="import" href="page/Page_1.html" id="page1">
</head>
<body>
    <script>
        console.log(page1.import.body.innerHTML);
    </script>
</body>

參考文章:https://www.web-tinker.com/article/20637.htmlspa

5、bootstrap的panel組件,或者easyui的window組件,有點相似這個效果;code

相關文章
相關標籤/搜索