且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

有什么东西作为“即时事件”在Javascript中?

更新时间:2023-11-28 23:16:58

Javascript中没有即时事件将永远不会被中断处理事件。

There is no thing as "immediate events" in Javascript, normally code will never be interrupted to handle events.

具有模态弹出窗口(如alert)的情况是唯一的例外。在某些浏览器中,当您调用警报时,方法中的代码可以设置为保持,并且在警报打开时发生事件。通常,在警报打开时,没有需要处理的事件,但显然您已经发现异常。

The case with modal popups like alert is the only exception. In some browsers the code in a method can be put "on hold" when you call alert, and there are events happening while the alert is open. Normally there would be no events that needed handling while the alert is open, but obviously you have found an exception.

通常,运行到完成原则是规则。除非您使用 alert 提示符,否则您可以依赖运行的代码不中断,直到退出函数。在代码运行时,浏览器实际上没有什么发生;没有页面更新,甚至GIF动画移动,而有Javascript运行。

Normally the "run-to-completion" principle is the rule. Unless you use something like alert or prompt, you can rely on the code being run uninterrupted until you exit your function. Actually nothing happens in the browser while the code is running; there are no page updates, not even GIF animations move while there is Javascript running.