Hi I would like to customize my pop up for leaving a page, is there any simple way to do that?
I am using simple jQuery
$(document).ready(function() {
var myPopUp = $('#pop-up').css('display', 'block');
$(window).bind('beforeunload', function(){
return 'load my pop up here instead of the default browser message';
});
});
my html for the pop up is which is hidden by default
<div id="pop-up">
<h2>Are you sure wanna leave</h2>
<a href="#">Leave</a>
<a href="#" class="close">Stay</a>
</div>
Thanks
This question have been asked and answered in several stackoverflow posts such as this one
If you can also elaborate on what the circumstances of leaving the "page", you could probably get a better and proper answer. If you want to warn that user should save before then checkout the top post of the link. If you just want to warn before you leave the page, try this answer that user Hunter left: