How to know if user close a webpage?

Discussion in 'PHP' started by chxxangie, Nov 20, 2007.

  1. #1
    for example like press the 'X' button on title bar...
    is it possible to capture the event???
     
    chxxangie, Nov 20, 2007 IP
  2. phpl33t

    phpl33t Banned

    Messages:
    456
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You will need to use javascript. Php cannot tell what is going on with the browser. Javascript does communicate with the browser though.
     
    phpl33t, Nov 20, 2007 IP
  3. bartolay13

    bartolay13 Active Member

    Messages:
    735
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    98
    #3
    <body onunload="jsfunction()">

    then on your jsfunction() use ajax to send the info to the server side and alert you if the window is closed
     
    bartolay13, Nov 20, 2007 IP
  4. chxxangie

    chxxangie Peon

    Messages:
    54
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    thanks for helping...:)
     
    chxxangie, Nov 21, 2007 IP