hi,
if your requirement is to alert the user on the browser window close then it can also be achieved like this:
var inFormOrLink;
$('a').live('click', function () { inFormOrLink = true; });
$('form').bind('submit', function () { inFormOrLink = true; });
$(window).bind("beforeunload", function () {
return inFormOrLink || confirm("Do you really want to close?");
});
I tested it in both FireFox and Chrome