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 6 of 6
  1. #1
    Regular Coder
    Join Date
    Apr 2003
    Location
    Seoul, Korea
    Posts
    329
    Thanks
    0
    Thanked 0 Times in 0 Posts

    saving leaving time

    I like to make a user to visit goodbye.html page whe he or she leaves my site.

    Let's suppose my site has just two pages, ie index.html and goodbye.html.


    if the user closes the winodw or enters another address into address input box of the browser, it is forced to visit the goodbye page, or the goodbye page is popped up.


    My purpose on this is saving the leaving time into my database.

    will you show me the right way for this?

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I would recommend something like this, as it would be the least intrusive and won't be blocked by popup blockers
    Code:
    <script type="text/javascript">
    onunload = function()
    {
        var i = new Image();
        i.src = "goodbye.html";
    }
    </script>
    And let your server-side code in goodbye.html save the IP and time to the DB.
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”

  • #3
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    Yeah, cuz redirecting someone after they type an address in to some other place would be quite rude.
    OracleGuy

  • #4
    Regular Coder
    Join Date
    Apr 2003
    Location
    Seoul, Korea
    Posts
    329
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    <html>
    <head>
    
    <script type="text/javascript">
    onunload = function()
    {
        var i = new Image();
        i.src = "goodbye.htm";
    }
    </script>
    
    </head>
    
    <body>
    
    this is test page.<br>
    
    <a href=another.htm> another page </a>
    
    
    </body>
    </html>
    The above is the whole code of the test.htm.

    When I click the close button(x button) to close the window,
    or
    When I click the link to move to another.htm,
    or
    When I enter a new address in the address input box

    I can't find any trace of it visiting goodbye.htm.

    Do you see something wrong in my code?
    Last edited by joonstar; 10-19-2003 at 06:24 AM.

  • #5
    Regular Coder
    Join Date
    Apr 2003
    Location
    Seoul, Korea
    Posts
    329
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes, it is quite rude. oracleguy


    But this is the first step to find ways for getting some information of user's response.

    My target is saving the leaving time without any intrusion.

  • #6
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    Is your code on your goodbye page work? Double check that to make sure it is doing everything correctly.

    That'd be my guess.
    OracleGuy


  •  

    Posting Permissions

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