Mobile Safari/Webkit 窗口焦点事件
我想知道当用户切换回“您的”页面窗口时是否有可能收到事件?当用户打开新选项卡然后切换回页面的选项卡或用户关闭 safari 然后再次打开它时,可能会发生这种情况。
我希望能够在收到此事件后更新页面上的内容。我现在使用 setInterval 来完成此操作,但是当用户专注于您的窗口时最好没有延迟。
谢谢!
I am wondering if it is possible to get a event when the user switches back to "your" page's window? This could happen either when the user opens a new tab and then switches back to your page's tab or when the user closes safari and then opens it again.
I want to be able to update content on the page once I get this event. I am using a setInterval to accomplish this now, but it would be nice to not have the delay when the user focuses on your window.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这个问题得到解决的可能性似乎很小:
我创建了 this 脚本来记录尽可能多的 WebKit 事件(事件名称取自 http://svn.webkit.org /repository/webkit/trunk/Source/WebCore/dom/EventNames.h),并且在离开/带到前台 Safari 时似乎不会触发任何事件。
The chance of this one getting resolved seems small:
I created this script to log as many WebKit events as possible (event names taken from http://svn.webkit.org/repository/webkit/trunk/Source/WebCore/dom/EventNames.h), and it doesn't seem to trigger any event upon leaving/bringing to front Safari.
我一直在深入研究,发现再次激活窗口时会触发
focus
事件。它应该是可行的(使用 jQuery):
这个事件可能比需要的更频繁地触发,但它对我有用。
I've been digging around and found that a
focus
event is fired when the window is activated again.It should be doable like this (using jQuery):
This event is probably fired more often than needed, but it worked for me.