Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
266 views
in Technique[技术] by (71.8m points)

google chrome - Document.hasFocus() always returns true when print dialog is opened in Edge on Windows 10

I was trying to use window.setInterval() API to check the result of document.hasfocus(). Normally, when we click to another browser tab or another application, the document.hasfocus() of one page will return false. However, when I tried to print a webpage in Edge, and with the print dialog opened, I found the document.hasfocus() always returns true, and it shouldn't be, cause the print dialog doesn't belong to the webpage. This only happens on Windows platform(It works fine on Edge for Mac). In fact, this also happens on Chrome for Windows10.

The repro steps:

  1. Open any webpage with Edge.
  2. Open devtools and keep checking document.hasFocus().
  3. Print the webpage and shows the print dialog of Edge.
  4. document.hasFocus() always show true no matter where we click to(another tab or another application).

I am not sure whether this is a bug of Edge or Web APIs, so I think I should submit an issue here to seek for some help. Any workaround that can fix this? Thanks in advance for your kind help.

question from:https://stackoverflow.com/questions/65661939/document-hasfocus-always-returns-true-when-print-dialog-is-opened-in-edge-on-w

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.9k users

...