-
import引入
href链接引入的html文件,id可以看做页面引导,在script中用到
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>title</title>
<!--import引入-->
<link rel="import" href="top.html" id="page1"/>
<link rel="import" href="fotter.html" id="page2"/>
</head>
<body>
<!--import在头部引入,里面是啥就是啥-->
<script type="text/javascript">
document.write(page1.import.body.innerHTML);
</script>
<!--本页面内容-->
你好呀!
网页主体。
<script type="text/javascript">
document.write(page2.import.body.innerHTML);
</script>
</body>
</html>
-
借助jQuery
div+$("#page1").load("b.html")
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>title</title>
</head>
<body>
<div id="page1"></div>
<div id="page2"></div>
<script>
$("#page1").load("page/Page_1.html");
$("#page2").load("page/Page_2.html");
</script>
</body>
</html>
参考:
网友评论