Internet explorer internet explorer上的异步消息
我正试图解决一个问题。基本上,我需要在长时间运行的Javascript代码上显示“加载消息”,并在代码结束时将其隐藏,例如: showMessage() executeMyCode() 隐藏信息() 然而,我在Internet Explorer上运行时遇到了一些问题,现在看起来页面在所有脚本代码完成之前都是冻结的,这可能会让用户感到恼火。我尝试了一种使用setTimeout()的方法,但这不起作用,你们有人解决了这个问题吗?谢谢你的帮助Internet explorer internet explorer上的异步消息,internet-explorer,asynchronous,message,Internet Explorer,Asynchronous,Message,我正试图解决一个问题。基本上,我需要在长时间运行的Javascript代码上显示“加载消息”,并在代码结束时将其隐藏,例如: showMessage() executeMyCode() 隐藏信息() 然而,我在Internet Explorer上运行时遇到了一些问题,现在看起来页面在所有脚本代码完成之前都是冻结的,这可能会让用户感到恼火。我尝试了一种使用setTimeout()的方法,但这不起作用,你们有人解决了这个问题吗?谢谢你的帮助 提前感谢。您可以这样做: function showMes
提前感谢。您可以这样做:
function showMessage(){
/* show message */;
window.delay=setTimeout(executeMyCode,100); // Give some time to browser to render message
return;
}
function executeMyCode(){
clearTimeout(window.delay);
/* execute long running code */
/* hide message */
return;
}
虽然在执行长代码时浏览器仍将被冻结,但用户现在可以看到消息