文章詳情頁
javascript - setInterval和document.write在IE瀏覽器下的沖突
瀏覽:129日期: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. showpassword里的this 是什么意思?代表哪個元素2. 對mysql某個字段監控的功能3. java - Spring MVC怎么實現提交表單后跳轉?4. javascript - windows下如何使用babel,遇到了困惑5. javascript - js中向下取整6. python - 為什么正常輸出中文沒有亂碼,zip函數之后出現中文編程unicode編碼的問題,我是遍歷輸出的啊。7. html - vue項目中用到了elementUI問題8. JavaScript事件9. java - input file類型上傳了一個文件,想計算一下上傳文件的大小?10. javascript - table列過多,有什么插件可以提供列排序和選擇顯示列的功能
排行榜
