2013-05-17 53 views
1

我已经包括以下内容来完成它。但是由于这个原因,页面上的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> 
+0

页脚你不应该添加的onload在文档准备 – swetha

+0

JavaScript元素在当前页面或存在于header.html中的人? – Sanjeev

+0

我需要在header.html文件中添加.js文件链接,否则Javascript元素就会在头文件中出现。如果我这样做,它会影响当前页面上的js元素,其中包含头文件。 :( – user2389670

回答

0

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

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

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