文章详情页
javascript - setInterval和document.write在IE浏览器下的冲突
浏览:187日期: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. ionic 项目 ionic build android -release 打包时报错2. python3.x - python3.5.2安装时make报错求助3. javascript - 在使用 vue.js element ui的时候 怎么样保留table翻页后check的值?4. javascript - vue组件通过eventBus通信时,报错a.$on is not a function5. mysql_replication - mysql读写分离时如果单台写库也无法满足性能怎么解决6. mac里的docker如何命令行开启呢?7. angular.js - 如何控制ngrepeat输出的个数8. html - vue项目中用到了elementUI问题9. python - 如何用pandas处理分钟数据变成小时线?10. html5 - weex H5端的使用,怎么跑起来?
排行榜

网公网安备