|
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?'
|
|
Copyright © 1996-2008 irt.org, All Rights Reserved.