gpt4 book ai didi

javascript - Page Visibility Api,打开错误

转载 作者:行者123 更新时间:2023-11-29 21:38:33 24 4
gpt4 key购买 nike

我对这个 API 有一个问题。一切正常,但是当我打开某些东西或切换到某个将在浏览器上运行的应用程序时(我没有最小化浏览器,只是在它上面打开了一些东西),api 不起作用并且隐藏状态 = false。有人知道如何解决吗?

最佳答案

考虑https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibility_API和 Mozilla 的演示这是预期的行为。文档中提到的“焦点”仅适用于选项卡,而不适用于整个浏览器窗口(如果我理解正确的话)。

为了完整起见,这是来自http://www.w3.org/TR/page-visibility/ :

On getting, the visibilityState attribute MUST return the DOMString visible if the Document contained by the top level browsing context is at least partially visible at on at least one screen. This is the same condition under which the hidden attribute is set to false.

To accommodate accessibility tools that are typically full screen but still show a view of the page, when applicable, on getting, the visibilityState attribute MAY return the DOMString visible when the User Agent is not minimized but is fully obscured by other applications.

要检查整个窗口是否在焦点上,您可以使用 document.hasFocus(),如下所述:https://stackoverflow.com/a/3479960/2445864

关于javascript - Page Visibility Api,打开错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34043246/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com