我有一個wordpress網站,我正試圖爲它加載一個.js文件。出於某種原因,我無法讓它工作。在wordpress中調用js文件
JS文件是在http://www.leadcomm.net/pricequotejs.js
,我把這個頁腳:
<script type="text/javascript">
if (window.location.href == 'http://www.leadcomm.net/cost-estimate/') {
var js = document.createElement('script');
js.setAttribute("type","text/javascript");
js.setAttribute("src", "pricequotejs.js");
document.getElementsByTagName("head")[0].appendChild(js);
}
</script>
什麼我做錯了任何想法?
我怎樣才能讓它只運行一個頁面?您可以使用 – Finx
在您的header.php文件中使用 <?php is_page('455') { }?> 使用此代碼。希望它有幫助。 – Gaurav
如果你的頁面是主頁然後使用這個: <?php is_home(){}?> – Gaurav