文章詳情頁(yè)
javascript - setInterval和document.write在IE瀏覽器下的沖突
瀏覽:114日期:2023-03-22 08:20:56
問(wèn)題描述
function reload(){ alert('ce');}window.onload=function(){ alert('a'); setInterval('reload()',1000); document.write('aaa');};
如上,同時(shí)有 setInterval 和 document.write在其他極速瀏覽器,chrome內(nèi)核瀏覽器里沒(méi)有問(wèn)題。但是在 IE11 瀏覽器里,setInterval 就會(huì)停止。怎么解決。謝謝。
問(wèn)題解答
回答1:document.write會(huì)隱式調(diào)用document.open。這樣會(huì)重構(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個(gè)像素?下一條:javascript - 求助在 requireJS 中,$(window).load() 里面的代碼 為什么不會(huì)執(zhí)行?
相關(guān)文章:
1. [python2]local variable referenced before assignment問(wèn)題2. 求救一下,用新版的phpstudy,數(shù)據(jù)庫(kù)過(guò)段時(shí)間會(huì)消失是什么情況?3. javascript - 求幫助 , ATOM不顯示界面!!!!4. mysql - 請(qǐng)問(wèn)數(shù)據(jù)庫(kù)字段為年月日,傳進(jìn)的參數(shù)為月,怎么查詢那個(gè)月所對(duì)應(yīng)的數(shù)據(jù)5. python - 如何判斷字符串為企業(yè)注冊(cè)名稱6. php - 微信開(kāi)發(fā)驗(yàn)證服務(wù)器有效性7. python中怎么對(duì)列表以區(qū)間進(jìn)行統(tǒng)計(jì)?8. javascript - 我的站點(diǎn)貌似被別人克隆了, google 搜索特定文章,除了域名不一樣,其他的都一樣,如何解決?9. javascript - js setTimeout在雙重for循環(huán)中如何使用?10. html - 移動(dòng)端radio無(wú)法選中
排行榜

熱門標(biāo)簽