...

View Full Version : Detecting if user closed the window



crca
01-10-2003, 03:23 AM
Hi!
I am making a perl site were you can make pets. (http://netpets.itgo.com)

Is there any way (ither in perl or javascript) to see if the user closes the window but NOT if he clicks on a link?

I have tried onUnload="(window.location='myperllogofffile.pl')" but then it will take me to the logoff script everytime!

Does anyone know a solution to this?

Thanks alot in advance,
Tim

Algorithm
01-10-2003, 04:04 AM
You could add an onClick event to every link that disables the onUnload event, like so:

<body [...] onLoad="closing=true" onUnload="(if(closing)window.location='myperllogofffile.pl')">
[...]
<a [...] onClick="closing=false">

Rather tedious, I admit, but it should work.

crca
01-10-2003, 05:02 AM
anything will help. thanks i shall tell you in a few days if it worked.

glenngv
01-10-2003, 08:36 AM
There is an IE-only solution.
see my suggestion in these threads:
http://codingforums.com/showthread.php?s=&threadid=6823
http://codingforums.com/showthread.php?s=&threadid=8563



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum