I am developing a multi-monitor web application in which there is a parent window and several children windows. I require to focus one of the children windows from another child window.
I have already checked many other questions and articles about this issue in the Internet and none of the workarounds are really working...
I have tried calling blur() before focus(), moveTo() after focus(), calling it inside setTimeout(), calling back to opener window, etc. with no success at all and no errors in console.
I have prepared a sample Plunker to test it:
https://embed.plnkr.co/plunk/uX1qZn9qgbdkdf2Q
To reproduce, follow these steps in the Plunker:
- In the parent window, introduce id 1 in the input text and click button "Open Window" and then repeat with id 2.
- In the child window 1, introduce id 2 in the input text and click button "Focus Window", the window will not focus.
- Doing the same in the parent window works, as it is the opener of the child window
A very strange case happens when you click the parent window and then click button "Focus Window" in the child window... it works! I don't really understand why but it might be related with parent window getting focus and having control of the child window or something like that. This can't be reproduced programatically though, it only works on user interaction ???
This is not consistent with method close(), which shows an error in console telling that it is not supported by security reasons in the browser. That seems ok to me and I would expect the same behaviour in focus(), blur(), etc.
Anybody has any valid workarround for focusing sibling windows in year 2020?
Thanks in advance!
Here are some other related questions in StackOverflow:
EDIT: I have modified the Plunker to add Custom Event but it doesn't work either. I have also posted a comment in this thread: https://javascript.info/focus-blur.