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.
精彩评论