I have a series of pages that open pop-ups (new tabs in Mobile Safari.) Each of these pop-ups should know when they are concentrated or not. On desktop computers, we use window.onblur and window.onfocus to control this behavior. However, none of these events work on the iPad. I also tried window.onpageshow and window.onpagehide , which also don't work at the right time. I have a test HTML file:
<html> <head> <script language="javascript"> console.log('Hello'); window.onblur = function(e) { console.log('blur'); }; window.onfocus = function(e) { console.log('focus'); }; window.onpagehide = function(e) { console.log('pagehide'); }; window.onpageshow = function(e) { console.log('pageshow'); }; </script> </head> <body> <a href="http://www.google.com" target="_blank">Click Me</a> </body> </html>
In theory, when you click "Click Me", you should get a blur event when a new window appears. But this does not happen on Mobile Safari. onpagehide and onpageshow also do not show love, they only help to detect when you are going to close the tab.
How can I get the behavior I'm looking for in Mobile Safari? Is it possible at all?
Josh k
source share