Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Jul 2002
    Location
    I forgot ;)
    Posts
    35
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Detecting if user closed the window

    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
    PM Me if you want the new URL for my forum!

  • #2
    Regular Coder
    Join Date
    Jul 2002
    Location
    USA
    Posts
    151
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #3
    New Coder
    Join Date
    Jul 2002
    Location
    I forgot ;)
    Posts
    35
    Thanks
    0
    Thanked 0 Times in 0 Posts
    anything will help. thanks i shall tell you in a few days if it worked.
    PM Me if you want the new URL for my forum!

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    There is an IE-only solution.
    see my suggestion in these threads:
    manipulating the window events
    How to trace browser close
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •