开发者

window.onfocus doesn't stop firing in Chrome

The window.onfocus event does not stop firing in C开发者_Python百科hrome. It is fine in every other browser. Here is my code:

window.onfocus = function() {
  alert('focused');
}

What is the best way to fix this?


That's the expected behavior because what's happening is that the alert makes the window object loose focus, and after closing the alert the focus is returned to the window object, firing the event again.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜