文章詳情頁
javascript - setInterval和document.write在IE瀏覽器下的沖突
瀏覽:132日期:2023-03-22 08:20:56
問題描述
function reload(){ alert('ce');}window.onload=function(){ alert('a'); setInterval('reload()',1000); document.write('aaa');};
如上,同時有 setInterval 和 document.write在其他極速瀏覽器,chrome內核瀏覽器里沒有問題。但是在 IE11 瀏覽器里,setInterval 就會停止。怎么解決。謝謝。
問題解答
回答1:document.write會隱式調用document.open。這樣會重構document,移除所有event事件和task。
可以用document.body.innerText代替document.write
function reload(){ alert('ce');}window.onload=function(){ alert('a'); setInterval('reload()',1000); document.body.innerText = 'aaa';};
標簽:
JavaScript
上一條:javascript - 為什么 body 高度比 canvas 高度多出4個像素?下一條:javascript - 求助在 requireJS 中,$(window).load() 里面的代碼 為什么不會執行?
相關文章:
1. docker - 各位電腦上有多少個容器啊?容器一多,自己都搞混了,咋辦呢?2. java - spring boot 如何打包成asp.net core 那種獨立應用?3. java - 在用戶不登錄的情況下,用戶如何添加保存到購物車?4. datetime - Python如何獲取當前時間5. docker start -a dockername 老是卡住,什么情況?6. javascript - nginx反向代理靜態資源403錯誤?7. docker網絡端口映射,沒有方便點的操作方法么?8. 安全性測試 - nodejs中如何防mySQL注入9. javascript - 關于apply()與call()的問題10. python - 調用api輸出頁面,會有標簽出現,請問如何清掉?
排行榜
