Browser doesn’t fire Blur before onBeforeUnload event
While playing around with the Dirty Forms plugin I realised that the blur event of an input was not being fired when refreshing the page. This happens in Chrome and FireFox (and most likely others). I decided I’d see what I could do to handle this, and came across the document.activeElement property which is available in all recent releases of browsers – apparently even IE – and it’s part of the HTML5 spec.
$(window).bind('beforeunload', function(){
if(document.activeElement) $(document.activeElement).blur();
});
Apple Says My Face Causes Cellular Interference
While lying on the couch coding tonight, I had my iPhone 4 tucked under my chin. I don’t know why – it was just comfortable. Anyway – after a while, it popped up with a message saying that I had attached an incompatible accessory and it would possibly cause cellular interference. Apparently my face is incompatible with the iPhone 4.
Event Target for Submit wrong in IE7
While working on the Dirty Forms plugin, I discovered – much to my annoyance that when firing the Submit event, IE7 passes the target property as a reference to the submit input (if you clicked it) rather than what every same browser does, which is pass the form as the target.
This is easily fixed with jQuery
var target = $(event.target);
if(!target.is('form')) target = target.closest('form');
jQuery Live Binding to Submit in IE7
While working on Dirty Forms, I was running into issues getting IE7 to work with binding to the Submit event on a form, using the .live() method.
It turns out that jQuery 1.4.2 has a bug which doesn’t allow this to work, so you should use 1.4.3 or higher.



