jasonzissman / TimeMe.js

A JavaScript library to accurately time how long a user views a web page, disregarding idle time and time when the tab or window is minimized.
MIT License
592 stars 124 forks source link

userHasLeftPage on click on Iframe #34

Open plfort opened 7 years ago

plfort commented 7 years ago

Hello, when the user click on an iframe on a page TimeMe.js considers that the user has left the page because a click on an iframe triggers 'blur' on the window.

Do you have an idea to solve this issue ?

jasonzissman commented 7 years ago

Sorry for the late reply! Unfortunately I had not considered iFrames when implementing TImeMe. If iFrame clicking triggers the blur event on window, then I will not be able to differentiate in between leaving the web page (say via alt-tab in Windows) vs. clicking an iFrame. I don't think we'll be able to fix this issue.

karthikbalajikb commented 5 years ago

Is this is fixed or any work around ? @jasonzissman

amorrisewr commented 1 year ago

I'm seeing this issue now. Nothing has been merged into this repo for almost 3 years but it appears that the fix here would be to check document.activeElement in the blur handler and not stop the timer if the element is an iframe.