Which event handler to use to record leaving page - onunload or onbeforeunload?
Posted
by symcbean
on Stack Overflow
See other posts from Stack Overflow
or by symcbean
Published on 2010-05-17T12:37:28Z
Indexed on
2010/05/17
12:40 UTC
Read the original article
Hit count: 280
Hi all,
Having not any answers to my previous questions about using javascript to measure page turn times, I'm going to start writing my own code (!).
To measure the length of tie it takes, I'm proposing dropping a cookie containing a timestamp when the user browses away from a page, then in a subsequent page, comparing that time with 'now' and sending back a request to a URL which will log the interval.
It seems that there are 2 possible handlers I could associate the first block of code with - the onunload() handler or the onbeforeunload()?
It's more important that it fail silently on browsers with no/broken support for the handler, than it be portable across every possible browser.
Any pointers? Gotchas?
TIA
C.
© Stack Overflow or respective owner