Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

Q1198 How can I check with the user that they really do want to leave my page?

irt.org | Knowledge Base | JavaScript | Misc | Q1198 [ previous next ]

Q1198 How can I check with the user that they really do want to leave my page?

Try the following, although its not guaranteed to work in Netscape Navigator:

<html>
<head>
<script language="JavaScript"><!--
function confirmIEleave() {
  event.returnValue = "Are you sure you want to leave this page?";
}

function confirmNSLeave() {
  if (!document.layers) return;
  if (!confirm('Are you sure you want to leave this page?'))
    window.location.href = 'javascript:void(0)';
}
//--></script>
</head>

<body onbeforeunload="confirmIELeave()" onUnload="confirmNSLeave()">

<p>
Navigate to another page to fire the before unload event.
</p>

</body>
</html>

Feedback on 'Q1198 How can I check with the user that they really do want to leave my page?'


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.