onunload (or onbeforeunload) will prevent user from navigating to another page.
Use the below JavaScript code
window.onbeforeunload = function()
{
return 'Are you sure you want to leave?';
};
Or with jQuery:
Or with jQuery:
$(window).bind('beforeunload', function()
{
return 'Are you sure you want to leave?';
});
No comments:
Write comments