PDA

For continued disscussion on this topic : onBeforeUnload Solution?



Shawn Moore
06-29-2000, 01:08 AM
Hi,
I have an IE5 based intranet application that needs to capture the onUnload or onBeforeUnload event and ask the end-user if this is the desired action.

Between the <HEAD> tags I have:

<script language="JavaScript">
<!--
function closeconfirmation() {
event.returnValue = " WARNING! ";
}
</script>
And in the <Body> tag I have:

onBeforeUnload="closeconfirmation()"

The problem I'm having is I have several popup windows open on the page. See? Everytime one of these functions is called my onBeforeUnload event is triggered. This is not a desirable effect.

Does anyone have a suggestion on how to correct this issue?

thanks

Vincent Puglia
06-29-2000, 03:58 AM
Hi,

you could try something like:

... onBeforeUnload = "if (window.name == 'MainWin') confirmation()">

and in the head tags:

<script language="javascript">
<!--
window.name = "WinMain"
//-->
</script>

This presumes you only want the one window to execute the code. (BTW: I haven't tested it, but it should work.)

vinny

JavaGod
06-29-2000, 11:54 AM
If I understand the issue, the script is activated no matter what window Unloads ? If this is the case, you might try to directly reference the window.

EXAMPLE:
self.onUnLoad etc,etc.



If I miscontrued the issue, feel free to correct me :)