2013-05-17 54 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>