calculate how long user stay in a page using javascript?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bhanu
Forum Commoner
Posts: 46
Joined: Thu Nov 05, 2009 4:25 am

calculate how long user stay in a page using javascript?

Post by bhanu »

Hi to all

can we calculate how long user stay in a page using javascript?

I write a page as a questionary

when you finish page 1 and click the button it will transfer to page 2 to continue question on page 2

I would like to know the time user spend on every page... and then show the record on last page

how to calculate and record ?

Need javascriptt code.

thank you
regards
bhanu
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: calculate how long user stay in a page using javascript?

Post by requinix »

No need for JavaScript that I can see.

I'm guessing you're imposing a time limit on the whole process? When the first page loads, record the current time somewhere in the session. On each page load after, compare the current time against the recorded time.
Post Reply