从浏览器检测 iPad 上的主页按钮点击事件
如何检测 iPad2 上的主页按钮点击?
当在 iPad2 上单击主页按钮时,我的应用程序需要发送更新服务器。
我尝试通过 jQuery 卸载、调整事件大小,但没有任何结果被触发。我在普通浏览器和从“添加到主屏幕”的链接上都尝试过相同的操作。
How can I detect the home button click on iPad2?
My application needs to send update the server when the home button is clicked on iPad2.
I have tried unload, resize event through jQuery, but nothing gets fired. I have tried the same on both normal browser and link from add to home screen.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您无法检测到按下主页按钮。您可以尝试当窗口/主体失去焦点时,这不能保证有效,因为我还没有测试过它。它还可能捕获其他事件,例如切换选项卡、关闭窗口等。
类似这样的可能可以工作
You can't detect a press on the home button. You could try for when the window/body loses focus, this isn't guaranteed to work though as I haven't tested it. It might also catch other events like switching tabs, closing the window etc.
Something like this may work
如果 Safari 中没有此类事件,则无法触发该事件。
由于网站未卸载,卸载将不起作用。
您可以尝试构建某种心跳机制并检查您的服务器是否某个客户端已停止发送心跳。
There's no way to fire an Event if there's no such Event in Safari.
unload won't work as the Site isn't unloaded.
You can try to build some sort of heartbeat mechanism and check on your server, if a certain client has stopped sending heartbeats.
窗口上的焦点和模糊事件可以很好地检测浏览器是否要进入后台或从后台返回。
The focus and blur events on the window are good to detect if the browser is going to or back from background.