PDA

View Full Version : Interupting onBeforeUnload event


timur
03-18-2003, 11:42 AM
I've got the pop-up window

When user fires on 'X' button on the top right of the window to close it I want to ask him a confirmation and if he fired 'Cancel' button to keep window open. I'm using a code like this:

onbeforeunload = function(){
...
return fasle;
}

The problem is that browser responds with dialog window asking a standart information.

Did anyone knows is it possible to keep the browser window opened without any standart prompts? Maybe 'onbeforeunload' is not the solution I need?

arnyinc
03-18-2003, 02:45 PM
Here's some documentation on it.

http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/events/onbeforeunload.asp

Specifically "The default statement that appears in the dialog box, "Are you sure you want to navigate away from this page? ... Press OK to continue, or Cancel to stay on the current page.", cannot be removed or altered."

You can inject your own question in the middle of those two strings, but you can't edit them.

<HTML>
<HEAD>
<script type='text/javascript'>
function checkit(){
event.returnValue = "Do you really really want to leave";
}
</script>
<body onbeforeunload="checkit()">
<form name="testform" method="POST" >
<input type="text">
</form>
</BODY></HTML>

timur
03-19-2003, 09:32 AM
awful news

really. very bad