I want to know if the user is focused on http or https.
Therefore, each time the user clicks on one of the child windows - I want to know which one is "active".
I checked the W3C. Page Visibility API
Is there a way to determine if a browser window is open?
But for me it worked only with tabs, but not with windows.
EDIT: And only checked on Parentwindow.
Any help?
Thanks in advance.
Here is what I got.
<html> <head> <title>checkfocus</title> </head> <body> <a href="javascript:loadChild()">Click me</a>. <script src="http://code.jquery.com/jquery-1.10.1.min.js"></script> <script type="text/javascript"> var w; var w2; function loadChild() { w = window.open("","",'width=400,height=200'); w.location.href="https://www.facebook.com"; w.moveTo(0,0) w.addEventListener('focus',function(){ console.log("w") }) w2 = window.open("","",'width=400,height=200'); w2.moveTo(400,0) w2.location.href="http://www.facebook.com"; w2.addEventListener('focus',function(){ console.log("w2") }) } </script> </body> </html>
Events are fired 2 times in chrome once, when the window is open and one time location.href is set ... but nothing after
source share