2015-06-11 33 views
0

我有一個index.html文件,我正在嘗試使用JavaScript爲我的頁腳添加客戶端。但是,我的「footer.htm」包括不顯示,只是文本是。我很確定我的JavaScript代碼存在問題。我知道我的footer.htm文件沒有問題。請幫忙!未在本地客戶端顯示的外部html文件

document.write('footer.htm');
<div id="Footer"> 
 
    <script type="text/javascript" language="javascript" src="footer.js"> 
 
    </script> 
 
</div>

+0

'document.write'將字面上寫你提供的文件的字符串。它不包含頁面中的文件。要做你需要的東西,你應該使用服務器端包含(如果你的主機上可用)或AJAX。 –

回答

0

假設你正在使用jQuery

<script type="text/javascript"> 
    $(document).ready(function(){ 
     $('#footer').load('footer.htm'); 
    }); 
</script>