Jump to content

Find if Window/Page is Closed


Baez

Recommended Posts

I'm not sure if this can be done in PHP (maybe JS?) but I wanted to see anyway.

 

I want to check if a visitor has closed the current window or page they were viewing. Can anyone point me in the right direction?

 

Thanks :)

Link to comment
Share on other sites

In theory, you would need repeated polls from the page in question (Javascript) to a script on the server which would record in a database/file when the page is open (PHP), and a third script (PHP) run very frequently (by the cron daemon) to check the database to notice when a page has stopped polling, and then take the appropriate action.

 

I think this is how the Google Analytics ajax figures out how long a user stays on each page.

Link to comment
Share on other sites

Hmm that does make sense thanks a lot :). I only need this to run on one page. And I'm assuming the best DB engine to use for this table would be MEMORY instead of MyISAM.

 

I'm just not sure if my VPS would be able to handle it!

 

Any tutorials or guides you know of to help me design this?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.