异步请求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.

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