Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Window.onbeforeunload popup does not show up on closing modal dialog box

28 views
Skip to first unread message

Pradeep Kumar

unread,
Feb 26, 2015, 6:41:39 AM2/26/15
to
Hi,
I am facing a weird problem in project website page. Someone could throw some light on this please.

I have the Js code with window.onbeforeunload event defined as below sample. This below code executes fine and throws the popup asking user confirmation if there are any changes etc.

But similar code in my project does not work. When user does some changes in first page and tries to close the page, the user confirmation pop up shows up. But when user tries to edit some thing and opens up the modal dialog and close the modal dialog and tries to close the page then, window.onbeforeunload fires but the user confirmatin pop up does not show. It simply closes the page.

HtmlPage1.html
<script language="javascript">
debugger;
window.onbeforeunload = handleOnBeforeUnload;
function handleOnBeforeUnload(event) {
debugger;
return "Any changes you have made will be lost if you close this page.";
}
</script>
<title></title>
</head>
<body>
<button onclick="window.showModalDialog('HTMLPage2.html')">Test...</button>
</body>
</html>
0 new messages