473,699 Members | 2,745 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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="javas cript">
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....onBefo reUnload='retur n confirmExit();' />

Thanks.

Kathy

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #1
0 1219

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
15888
by: Marcia Gulesian | last post by:
What code can I put in the 'onbeforeunload' event to cancel the 'unload' action (when user closes browser) and then present the user with an alert saying that he/she must use the logout button.
0
1858
by: Rick Lubanovic | last post by:
I have been working on a script to check if a page has changed before the user leaves the page. I have a call to a javascript function on the onbeforeunload event. This seems to work in most cases. However, in my testing, the onbeforeunload event is sent twice. This causes problems in certain cases where I want to suppress the "The page has changed" message, as in the case of a "Cancel" button being hit.
1
1699
by: RJN | last post by:
Hi I have an onbeforeunload event where in I call a server side script to release some locks on the databse. function releaseLock() { __doPostBack('btnUnlock',''); } <body onbeforeunload="releaseLock();>
1
2685
by: RJN | last post by:
Hi I have a pop-up window which has a task menu on its left which are nothing but links to different screens. This window also has a close button. On click of close button I do some server side operation and the window closes itself. Now the user can close the window by clicking on X(Top right corner) or by pressing Alt+F4 window. I want to atleast alert the user when he does these 2 things to inform he has not clicked on the close...
1
9744
by: lee_youjin | last post by:
I needed to defect when the user is clicking the IE X button ( top right). so I could execute the cleanup function. I was able to detect it using onbeforeunload event. Now I need to call the function in code behind from onbeforeunload event call. but that is where I have a problem... please refer my code below
8
2982
by: Brad Walton | last post by:
Hello. First post, but been doing a bit of reading here. I am working on a project in Java, but decided to switch over to C# after seeing some of the additional features I can get from C#. One of the big changes I want to make is event-driven code (rather than the linear flow I had in Java). I have spent a week or so searching Google, talking to a couple of programming friends, and just chewing on it in my brain. I think I have an ok handle...
2
2105
Frinavale
by: Frinavale | last post by:
I'm not sure what I'm doing wrong. I am attempting to configure my object so that the object's method is called during the onbeforeunload event of the page. I have it so that it calls the method during the begin request of an Ajax call to the server...I don't know why I can't get the onbeforeunload event to work Here's what I have (I'm using the Ajax.NET library): MyNamespace.MyClass = function(element) { ...
1
4990
Frinavale
by: Frinavale | last post by:
I don't have a clue how to work around this problem and I'm open to any suggestions on the topic.... In Internet Explorer it appears that the onbeforeunload event is fireing despite the fact that it is not a full page postback to the server that is occurring. This is causing a problem because I'm displaying a <div> that blocks the page's content during the onbeforeunload event (in order to be consistent with what happens when I block the...
0
8615
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9173
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8911
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5872
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4375
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4627
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3057
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2345
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2009
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.