Results 1 to 4 of 4

Thread: How can i detect that a user is trying to leave a page

  1. #1
    Join Date
    Apr 2009
    Posts
    102

    How can i detect that a user is trying to leave a page

    Is it possible for me to know that if any user tries to leave a particular page or trying to move on to a new site? I'm trying to build a mage editor and would like to know that after finishing teh above action, it should call for a PHP function that would probably would clean up the users images from the temp files by detecting their ip address. So, can any body tell me that whether it is possible for me to do so? Kindly provide me the correct solution for the above issue. Any kind of help would be appreciated.

  2. #2
    Join Date
    Apr 2008
    Posts
    1,948

    Re: How can i detect detect that a user is trying to leave a page

    You can use Ajax script on the page that connects to the server every 30-60 seconds to say, "I'm still here". If the server doesn't hear from a particular session id, say about in 3 minutes, then you can assume that they left the page. (Better to rely on session id's than going for IP addresse).

    There are Javascript events that can trigger the Ajax script on page close or navigating away but they seems to be very unreliable.

  3. #3
    Join Date
    May 2008
    Posts
    2,012

    Re: How can i detect detect that a user is trying to leave a page

    You can use a cookie for the user who try to open the edit, set the lifetime for the cookie on the same length as the timeout time, then you can make a check for the cookie to see if the user is the one who opened the and then allow that one to edit as long the text is locked (when it's saved the cookie is removed).

  4. #4
    Join Date
    Apr 2008
    Posts
    2,005

    Re: How can i detect detect that a user is trying to leave a page

    Hey you can go for image image trick, just follow the below code for doing it.

    unction unload() {
    var cleanup = new Image();
    cleanup.src = "Notify.asp";
    }

    <body onunload="unload()">
    Hope so it might help you out.

Similar Threads

  1. Difference between Master Page & User Control in asp.net
    By Samarth in forum Software Development
    Replies: 3
    Last Post: 05-12-2009, 05:07 PM
  2. Replies: 0
    Last Post: 07-01-2009, 09:18 PM
  3. Should I Accelerate or leave it
    By Maximus() in forum Motherboard Processor & RAM
    Replies: 3
    Last Post: 14-11-2008, 06:40 PM
  4. Internet Explorer Script Error (User Accounts page)
    By stripes in forum Windows XP Support
    Replies: 6
    Last Post: 25-04-2008, 10:20 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,145,892.27998 seconds with 17 queries