简体   繁体   中英

Focus method from window object doesn't work in IE(2020)

MDN says that window.focus() is compatible with IE https://developer.mozilla.org/en-US/docs/Web/API/Window/focus .

But if I open IE and write

x=window.open('https://blank.org')

And after I come back to the main tab and I do x.focus() is not working.

I found several similar posts, but they are all old, and the information referred to there is out of date.

Is this happening by default, or is a IE setting?

I can reproduce the issue in IE 11. I searched docs and find that it might be due to some security issues the method can't be used in IE 8+. You can refer to this article :

Windows Internet Explorer 8 and later. The focus method no longer brings child windows (such as those created with the open method) to the foreground.

It can work in modern browsers because they have different engines than IE so the function can work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM