Description :
This event fires before page leave .You can also ask confirmation on page leave.
In JQuery Use this syntax to bind Beforeunload Event
$(window).bind("beforeunload",function(event) {
if(hasChanged) return "You have unsaved changes";
});
And if You want to Perform some action on page leave and not want confirmation Dialog Box
$(window).bind("beforeunload",function(event) {
if(hasChanged) alert('Hello');
null;
});