異步請求javascript,document.write() 失效問題

a.php中異步請求b.php, 在b.php中引用了外部了js(http://www.google.com/test.js) , test.js中document.write(), 但發現直接運行b.php, test.js中的document.write()可以運行。但a.php異步請求b.php時,b.php中的document.write()不能運行。

google了一下,結果是異步請求的文件中document.write失效。但爲什麼會這樣,暫時還沒找到答案。


或者這種情況也是這樣的


<div id="craftysyntax"> 
   <script type="text/javascript"> 
      (function() { 
         // csc = "Crafty Syntax Chat" 
         var csc = document.createElement('script'); 
         csc.type = 'text/javascript'; 
         csc.async = true; 
         csc.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'example.com/chat/livehelp_js.php?eo=1&amp;department=2&amp;serversession=1&amp;pingtimes=15' + ('https:' == document.location.protocol ? '&amp;secure=Y' : ''); 
         var s = document.getElementById('craftysyntax'); 
         s.appendChild(csc, s); 
      })(); 
   </script> 
</div> 


FF中會報:A call to document.write() from an asynchronously-loaded external script was ignored.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章