Javascript – confirm leave the page

Javascript code to be used when you need a confirmation before leaving a page:


<script language="javascript" type="text/javascript">
window.onbeforeunload = confirmClose;
function confirmClose(){
return "Are you sure do you want to leave this page.";
}
</script>

Leave a Reply

Your email address will not be published. Required fields are marked *