[英]HTML - use common footer for all pages
I want to use common footer in all pages in my website.我想在我网站的所有页面中使用通用页脚。 I use this code for doing this:我使用此代码执行此操作:
index.html:索引.html:
<html>
<head>
<script src="js/jquery.min.js"></script>
<script>
$(function(){
$("#generalFooter").load("footer.html");
});
</script>
</head>
<body>
<div id ="generalFooter"></div>
</body>
</html>
footer.html:页脚.html:
<footer class="footer footer-distributed">
.
.
.
</footer>
It's working , Actually I want to know is it the best way for calling static footer in all of pages?它正在工作,实际上我想知道它是在所有页面中调用静态页脚的最佳方式吗?
I think its the best solution to include an HTML file.我认为它是包含 HTML 文件的最佳解决方案。
I tried your code and its working.我试过你的代码和它的工作。
Please check the paths of jQuery file and the footer.html file.请检查 jQuery 文件和 footer.html 文件的路径。
https://css-tricks.com/the-simplest-ways-to-handle-html-includes/ https://css-tricks.com/the-simplest-ways-to-handle-html-includes/
Use PHP使用 PHP
PHP offers a wonderful method to resolve this with the include() statement. PHP 提供了一种使用 include() 语句解决此问题的绝妙方法。 With this technique we can include any file we want within another file.使用这种技术,我们可以在另一个文件中包含我们想要的任何文件。
<body>
<!--header start -->
<?php include("includes/header.php"); ?>
<!--header end -->
<div clas"container"></div>
<!--footer start -->
<?php include("includes/footer.php"); ?>
<!--footer end -->
</body>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.