When someone tries to leave my website I want to show them pop up message. I tried to use window.onbeforeunload
function but it is not working.
<script language="JavaScript">
window.onbeforeunload = confirmExit;
function confirmExit(){
return "You have attempted to leave this page. If you have made any changes to the fields without clicking the Save button, your changes will be lost. Are you sure you want to exit this page?";
}
</script>
Hi Jonathan i want to show my custom messages in pop up. currently it shows default message - This page is asking you to confirm that you want to leave - data you have entered may not be save