我有一系列带有公共页脚的静态html页面,我希望从每个html文件中包含内容而不重复
e.g。
root
page1.html
page2.html
page3.html
footer.html
如何在不编写任何java脚本的情况下使页脚1,2和3使用footer.html作为页脚文件。我在这个问题How to include html file in another html file中看到了包含java脚本的答案,但我想知道它是否可能没有java脚本。
记住
答案 0 :(得分:1)
iframes是HTML,它们与PHP包含非常相似,但鉴于基于开放客户端的HTML与基于安全服务器的PHP相比,它具有更多的安全限制。
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<style>
</style>
</head>
<body>
<header>
<h1>iframes</h1>
</header>
<main>
<section>
</section>
</main>
<footer>
<iframe src="http://example.com"></iframe>
<iframe src="http://example.com"></iframe>
<iframe src="http://example.com"></iframe>
</footer>
</body>
</html>
答案 1 :(得分:0)
你不应该使用html,因为html是静态的,如果你想让动态网页尝试类似PHP的东西。
看看这个:https://css-tricks.com/forums/topic/how-to-include-php-headers-and-footers-on-html-site/
希望它有所帮助。