OnBeforeUnload event...where to run code BEFORE return msg?

K

Kathy Burke

I have a multiple page FRAME in asp.net in a tightly controlled intranet
app. If the user clicks the X close window/browser button, I simply want
to check that a certain Session variable equals something; if it does,
give the user a confirm box (javascript) that closing the window will
cause data loss; hitting OK processes the close.

I've found the javascript for the hmtl section, but it first sets a flag
variable (properExit) to false". Depending on my session variable, how
do I set the flag variable to true, to bypass the confirmExit function?

SCRIPT:
<script language="javascript">
var properExit = "false";

function confirmExit() {
if (properExit != "true") {
return "Closing the browser will cause loss of data.
To continue, click OK, to return to the form click
Cancel.";
}
}
</script>

<BODY....onBeforeUnload='return confirmExit();' />

Thanks.

Kathy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top