Friday, October 7, 2011

Onbeforeunload event using jQuery

JavaScript: window.onbeforeunload Event - Show “Are you sure you want to leave this page?” Message


Handle window.onbeforeunload event using jQuery

$(window).bind('beforeunload', function() {
return 'You have unsaved changes. If you leave the page these changes will be lost.';
});

Handle window.onbeforeunload event using straight JavaScript

window.onbeforeunload = function(e) {
return 'You have unsaved changes. If you leave the page these changes will be lost.';
};

How to Loop through all elements in a form using javascript

This is a simple method to Loop through all elements in a form using javascript