页面可见性API在窗口最小化时不适用于Chrome OS X [英] Page Visibility API not working on Chrome OS X when window is minimized

查看:194
本文介绍了页面可见性API在窗口最小化时不适用于Chrome OS X的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据谷歌的文档,他们已经实现了页面可见性API。
https://developers.google.com/chrome/whitepapers/pagevisibility



然而,从我的测试中,当我在Mac OSX 10.9上最小化浏览器时,它似乎没有触发事件。



这是我测试的代码:

  document.addEventListener(webkitvisibilitychange,handleVisibilityChange,false); 

完整执行:
http://jsfiddle.net/wvupJ/

解决方案

正如这个问题仍然是面向公众的Chromium bug。真正的工作显然是在案例246844 下完成的,不是公众可以访问(包括我自己)。

由于我无法看到修复的细节,我不确定它是否适用于较旧的Mac,但我从个人经验知道它至少起作用在小牛和优胜美地。



Chrome是最大的Mac浏览器(Safari,Chrome,Firefox)中的最后一个,它完全支持页面可见性API,所以它很快就会安全使用近期的Mac浏览器访问者依赖页面可见性API。

面向公众的面向Linux的页面可见性API( case 293128 )未解决,因此任何在Linux上使用Chrome浏览器的访问者比例都不应该超过然而,它依赖于页面可见性API。


According to Google's docs, they have implemented the Page Visibility API. https://developers.google.com/chrome/whitepapers/pagevisibility

However from my testing, it appears to not fire the event when I minimized the browser on Mac OSX 10.9.

This is the code I'm testing:

document.addEventListener("webkitvisibilitychange", handleVisibilityChange, false);

Full implementation here: http://jsfiddle.net/wvupJ/

解决方案

The page visiblity API is now supported for Mac as well as Windows since Chrome 42 (April of 2015), as noted on the still open public-facing Chromium bug for this issue. The real work was apparently done under case 246844, which is not accessible to the public (including myself).

Since I can't see the details of the fix, I'm not sure whether it applies to older Macs, but I know from personal experience that it works at least on Mavericks and Yosemite.

Chrome was the last of the major Mac browsers (Safari, Chrome, Firefox) to fully support the page visibility API, so it should soon be safe to rely on the page visibility API for visitors using recent Macs.

The similar public-facing bug for the page visibility API for Linux (case 293128) is unresolved, so any site with a large percentage of visitors using Chrome on Linux should not yet rely too heavily on the page visibility API, however.

这篇关于页面可见性API在窗口最小化时不适用于Chrome OS X的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆