我想创建包含在多个 html 页面上的通用页眉和页脚页面。
我想使用 JavaScript。有没有办法只使用 html 和 JavaScript 来做到这一点?
我想在另一个 html 页面中加载页眉和页脚页面。
你可以通过以下方式完成此操作jquery.
将此代码放入index.html
<html>
<head>
<title></title>
<script
src="https://code.jquery.com/jquery-3.3.1.js"
integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60="
crossorigin="anonymous">
</script>
<script>
$(function(){
$("#header").load("header.html");
$("#footer").load("footer.html");
});
</script>
</head>
<body>
<div id="header"></div>
<!--Remaining section-->
<div id="footer"></div>
</body>
</html>
并将这段代码放入header.html
and footer.html
,在同一位置index.html
<a href="http://www.google.com">click here for google</a>
现在,当您访问index.html
,您应该能够单击链接标签。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)