文章詳情頁
javascript - setInterval和document.write在IE瀏覽器下的沖突
瀏覽:131日期: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內(nèi)核瀏覽器里沒有問題。但是在 IE11 瀏覽器里,setInterval 就會停止。怎么解決。謝謝。
問題解答
回答1:document.write會隱式調(diào)用document.open。這樣會重構(gòu)document,移除所有event事件和task。
可以用document.body.innerText代替document.write
function reload(){ alert('ce');}window.onload=function(){ alert('a'); setInterval('reload()',1000); document.body.innerText = 'aaa';};
標(biāo)簽:
JavaScript
上一條:javascript - 為什么 body 高度比 canvas 高度多出4個像素?下一條:javascript - 求助在 requireJS 中,$(window).load() 里面的代碼 為什么不會執(zhí)行?
相關(guān)文章:
1. 關(guān)docker hub上有些鏡像的tag被標(biāo)記““This image has vulnerabilities””2. Span標(biāo)簽3. css - 求推薦適用于vue2的框架 像bootstrap這種類型的4. docker-machine添加一個已有的docker主機(jī)問題5. android新手一枚,android使用httclient獲取服務(wù)器端數(shù)據(jù)失敗,但是用java工程運(yùn)行就可以成功獲取。6. css - 關(guān)于div自適應(yīng)問題,大家看圖吧,說不清7. angular.js使用$resource服務(wù)把數(shù)據(jù)存入mongodb的問題。8. java - Collections類里的swap函數(shù),源碼為什么要新定義一個final的List型變量l指向傳入的list?9. python - django如何每次調(diào)用標(biāo)簽的時候都取隨機(jī)數(shù)據(jù)10. SessionNotFoundException:會話ID為null。調(diào)用quit()后使用WebDriver嗎?(硒)
排行榜

熱門標(biāo)簽