文章詳情頁
javascript - setInterval和document.write在IE瀏覽器下的沖突
瀏覽:202日期: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. boot2docker無法啟動2. docker-compose中volumes的問題3. java - SSH框架中寫分頁時service層中不能注入分頁類4. docker容器呢SSH為什么連不通呢?5. dockerfile - 為什么docker容器啟動不了?6. docker安裝后出現Cannot connect to the Docker daemon.7. nignx - docker內nginx 80端口被占用8. node.js - antdesign怎么集合react-redux對input控件進行初始化賦值9. 關docker hub上有些鏡像的tag被標記““This image has vulnerabilities””10. 關于docker下的nginx壓力測試
排行榜

網公網安備