【问题标题】:I want common header and footer all over pages我想要所有页面上的通用页眉和页脚
【发布时间】:2013-05-17 05:58:44
【问题描述】:

我已经包括以下内容来完成它。但是页面上的 Javascript 元素因此无法正常工作。

<html>
<head>
    <script type="text/javascript">
        $(document).ready(function(){ 
        $.get("header.html", function(data) {
    $("#header").html(data);
       });
     });
   </script>
</head>
<body>
<div id="header"></div>
<content>
</content>
</body>
</html>

【问题讨论】:

  • 你应该添加onload not on document ready
  • 当前页面中的javascript元素或header.html中存在的那些?
  • 我必须在 header.html 文件中添加 .js 文件链接,否则头文件中存在的 Javascript 元素无法正常工作。如果我这样做,它会影响我包含头文件的当前页面上的 js 元素。 :(

标签: header custom-headers


【解决方案1】:

如果你能设法在你的机器上设置一个像 XAMPP 这样的虚拟服务器,然后使用 PHP,你可以用一行代码在任何你想要的页面上包含页眉和页脚。

<header><?php include 'header.php';?></header>

和页脚

<footer><?php include 'footer.php';?></footer>

【讨论】:

    猜你喜欢
    • 2016-04-30
    • 1970-01-01
    • 2015-03-13
    • 1970-01-01
    • 2019-02-17
    • 2018-02-02
    • 1970-01-01
    • 2016-01-24
    • 1970-01-01
    相关资源
    最近更新 更多