Click to See Complete Forum and Search --> : opening popup window on closing main window


lepelle
12-15-2003, 05:32 AM
In a dynamic website, I use a popup window without browser buttons and other browser stuff for the interactive dialogs.

So when you login a popup window provides you with everything you need. This way I can better control what the user can do. In my functionality I have built in a record control function, which locks a database records, once it is opened for editing. It is released when the user cancels or updates or deletes the record. If records are still locked when you try to logout you are asked to release such records.
Since I cannot prevent a user from clicking the close button in the windows user interface, or using alt F4 to close, I need to popup the logout page once somebody is trying to close the interactivitity window.

Need to popup a new window when application is trying to close a window.
Has anybody got an answer to this question?
Thanks,
Per Jansson

TheBearMay
12-15-2003, 06:56 AM
You could place an onunload in the body tag...

lepelle
12-15-2003, 07:23 AM
I have tried onUnload but it will pop up for everything you do, clicking a button or a link leaving the page.
Can I control it to react only to the close window button?

TheBearMay
12-15-2003, 07:47 AM
You'll probably have to write a routine to check to see why you're leaving then. Easiest way may be to set a variable and check it with the onunload method.



var reasonCode;

function checkReason(){
if (reasonCode = 1) { //link out
...
else { // window closing
....

<body ...onunload="checkReason()">
...
<a href="somelink.html" onclick="reasonCode=1;">....

lepelle
12-15-2003, 08:21 AM
Thanks!