在html中引入另一个html文件

在html文件中引入另一个html文件的方法:
一、div+$(“#page1”).load(“b.html”) 代码如下
<body>
<div id="page1"></div>
<div id="page2"></div>
<script>
$("#page1").load("page/Page_1.html");
$("#page2").load("page/Page_2.html");
</script>
</body>

二、iframe 代码如下
<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>

三、object引入 代码如下
<head>
<object style="border:0px" type="text/x-scriptlet" data="page/Page_1.html" width=100% height=150>
</object>
</head>

四、import引入 代码如下
<head>
<link rel="import" href="page/Page_1.html" id="page1">
</head>
<body>
<script>
console.log(page1.import.body.innerHTML);
</script>
</body>

还有个人认为最简单的 直接用php文件写.php文件,用include引入,是真简单。



作者:Alex丶张佩
链接:https://www.jianshu.com/p/165d535a00a7
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

posted on 2021-03-27 22:04  剩余价值  阅读(3033)  评论(0编辑  收藏  举报

导航