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

Categories

0 votes
455 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.


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

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...