How can I refocus focus on any other browser tab? I have tried:
window.opener.focus (); No use it works only when the window is not docked.
I need it to work in Chrome, IE9 / 10, Firefox, and Safari.
Internet Explorer also has problems setting the focus in the hair window. Like when using:
var windowRef = window.open (url); Then from the same tab later:
windowRef.focus (); // Right in Chrome, does not seem to work in IE ...
What do you want to achieve? Focus inside to set another window on the first link / button / form field / whatever? Or other windows (Browser tab) to create active browser tabs? Anyway - opener.focus () The call does not work because the two windows do not serve the same root try to set up a communication channel to resolve it so In the Openers document, listen to an event like this: window.addEventListener ('message', function (event) {window.focus ();} , false); and in the open window, send the message like this:
opener.postMessage ('foo', '*'); Unfortunately, I can not test if it's still working. (I think it should be, though ...)
To add some things, though:
- Support some legacy crap browsers (see) message Do not do it. The proceedings are, though. :)
- I used W3 standard notation to add the event listener. Use IE8 and below to their proprietary
attachEvent equals. - You should change the original wildcard with
No comments:
Post a Comment