window.focus() not working in Google Chrome

后端 未结 16 1728
余生分开走
余生分开走 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:43

    I was only able to solve my problem when I used setTimeout() and encapsulated the focus() inside an anonymous function. Here is an example:

    setTimeout(function () {
       myField.focus();
    }, 0);
    

提交回复
热议问题