how to freeze your browser with blur()
Here’s something I do so often, it’s embarassing.
I use alert() often in debugging. I know there are fancier methods of tracing variables using the Firebug console, but I like to debug in multiple browsers, and an alert() is quick way to inject a little debug message into JS code.
But when you alert(), it pulls focus away from the window, which is equivalent to a blur(). If you’re testing issues with focus and blur, it’s easy to get yourself into a situation where the browser is alerting and blurring in a loop you can’t escape. When this happens the only solution is to open Task Manager, and shut down the app.
You can easily cripple a browser just by doing this:
window.addEvent(’blur’,function(){
alert(’you blurred’);
});
Here I’ve used the mootools library for its addEvent() method, but obviously you could do the same thing with using any variation of the “onblur” event Listener.
I guess I should be more careful, but I wish that browsers would handle this situation better, perhaps by providing a way to close an unwanted alert box without triggering a cascade of window events.
Filed under AJAX + Javascript





