javascript - Conflict between setInterval and document.write under IE browser
世界只因有你
世界只因有你 2017-07-05 10:48:22
0
1
1032
function reload(){
    alert("ce");
}
window.onload=function(){
    alert("a");
    setInterval("reload()",1000);
    document.write("aaa");
};

As above, there is no problem in other fast browsers and chrome kernel browsers with setInterval and document.write at the same time. But in IE11 browser, setInterval will stop. How to deal with it. Thanks.

世界只因有你
世界只因有你

reply all(1)
Ty80

document.write will implicitly call document.open. This will reconstruct the document, removing all event events and task.

You can use document.body.innerText instead of document.write

function reload(){
    alert("ce");
}
window.onload=function(){
    alert("a");
    setInterval("reload()",1000);
    document.body.innerText = "aaa";
};
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template