window.focus() not working in Google Chrome

后端 未结 16 1776
余生分开走
余生分开走 2020-11-28 05:07

Just wondering if Google Chrome is going to support window.focus() at some point. When I mean support, I mean have it work. The call to it doesn\'t fail, it jus

16条回答
  •  日久生厌
    2020-11-28 05:29

    I simply use this line of code here to refocus, it's the best thing that's worked for me so far:

    window.open('', 'NameOfTheOpenedWindow').focus();
    

    thanks to this answer [here](https://stackoverflow.com/a/30758862/10706668"Answer by dileepar")

    I also made a [jsfiddle](https://jsfiddle.net/Foxygaming9978/6gc38f5x/"jsfiddle popup refocus testing") for testing.

    I hope this helps

提交回复
热议问题