if user is on page for more than 30 seconds, do something


using a webbrowser
Who is Participating?
Beverley PortlockCommented:
This is probably more a javascript question than PHP since we are talking about events on the client PC.  However HTTP refresh could also work. Basically, set up an HTTP-EQUIV on the web page like so

<meta http-equiv="refresh" content="30;url=http://example.com/">

This would wait for 30 seconds (the 30; bit) and then divert the user to example.com (the url=http://example.com/)

I guess it depends on what you mean when you say 'do something'
Ray PaseurCommented:
This kind of event triggering does not occur on the server side because in the RESTful client-server model the client initiates requests and the server serves up the response.  So when you use the meta-refresh your HTML is, in effect, causing the client to make a new request.  BTW, it is a deprecated piece of the HTML puzzle, but it works perfectly well, at least today.

Another alternative might be to use some kind of AJAX call and count up to 30 seconds.
rgb192Author Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.