I already asked a similar question, but I need it for a more specific case, so I decided to ask a new question so as not to mix things up.
Check if the window has focus
1. I make a PTC website where users get paid for visiting sites in x seconds.
2 .. An ad looks like this: a new page opens containing two things: the top panel with a counter and an iframe that contains the advertiser's site).
3. I want to make the user see this page in x seconds for which the advertiser paid.
4. To check if the user sees the page, IMO, I need to check if the document or iframe has focus.
Problems:
1. I cannot use window.onblur or window.onfocus , as the user may lose focus before loading the page and bypass these commands. 2. I cannot use hasFocus() in an iframe because Chrome makes this error: Blocked a frame with origin "xxx" from accessing a frame with origin "yyy". Protocols, domains, and ports must match. Blocked a frame with origin "xxx" from accessing a frame with origin "yyy". Protocols, domains, and ports must match.
I know two similar sites that do this, but their javascript is so weird that I can't understand a single line. (neobux.com and clixsense.com)
I'm going crazy with this because I tried so many things and none of them worked, I really need help with this. Thanks!
user2536244
source share