0
我想在我的頁面中顯示加載了AJAX/jQuery-JSON的廣告。如何使用javascript的document.write加載腳本
- 腳本:
- 文件xxxxx.js包含到document.write();
如何集成此腳本並使document.write被解釋。 以及爲什麼它不起作用?
這裏是我的測試顯示腳本執行,因爲警報('你好1')顯示,但不包含alert.write('你好2')的document.write;
直接調用文件到DOM執行井 「你好1」 和 「你好2」
test.js
alert("hello 1");
document.write('<scr'+'ipt type="text/javascript">alert("hello 2");</scr'+'ipt>');
指數:
<body>
<script>
function loadScriptJs() {
var s = document.createElement('script');
s.src = 'test.js';
s.type = 'text/javascript';
document.getElementById("pub").appendChild(s);
}
</script>
<div id="pub">
PUB A AJOUTER CI DESSOUS EN JAVASCRIPT :
<!-- appel direct de la pub
<script src="test.js" type="text/javascript"></script> -->
</div>
<script> loadScriptJs(); </script>
</body>
對不起,我的英語:) 謝謝bfavaretto,但我不能使用,爲了簡單的解決方案 使每個負載一擊:我必須加載腳本每個加載內容,該函數將加載後執行我的內容 – beberahim
好的,但是你不能在'test.js'中使用document.write。查看我的更新。 – bfavaretto