0
我在廣告空間上設置了一些橫幅區域 - 我試圖加載腳本標記使用jquery,以便他們加載頁面後加載。然而它不工作。這是我的代碼來做到這一點。試圖加載廣告客戶腳本標記異步 - 不工作
這裏是我使用包括腳本標籤功能:
function jsinclude(file, dom) {
if (document.createElement && document.getElementsByTagName) {
if(dom=='undefined')
var dom = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
script.setAttribute('type', 'text/javascript');
script.setAttribute('src', file);
script.setAttribute('charset',"utf-8");
dom.appendChild(script);
} else {
alert('Your browser can\'t deal with the DOM standard. That means it\'s old. Go fix it!');
}
}
這裏是怎麼了調用該函數:
$(function(){
jsinclude('http://ads.advertisespace.com/somethingsomething.js', document.getElementById('location-of-banner-1'));
jsinclude('http://ads.advertisespace.com/somethingsomething.js', document.getElementById('location-of-banner-2'));
})
結果腳本標籤插入正確的地方,但橫幅不顯示,即腳本文件中涉及的代碼永遠不會執行。我怎樣才能解決這個問題。
undefined是一個狀態不是字符串! – Bakudan
dom不是'head'元素。示例'.js'文件也不包含JavaScript代碼。你的真人包含JavaScript代碼嗎?最後,廣告服務不應該讓警報出現。 – pimvdb