有没有办法在Mobile Safari for iOS设备上使用window.onbeforeunload? [英] Is there any way to use window.onbeforeunload on Mobile Safari for iOS devices?
问题描述
看起来Apple已禁用iOS设备(iPhone,iPad,iPod Touch)的window.onbeforeunload事件。遗憾的是,我找不到任何关于此事件在Mobile Safari中不起作用的文档。
Looks like Apple has disabled the window.onbeforeunload event for iOS devices (iPhone, iPad, iPod Touch). Unfortunately I can't find any documentation as to why this event doesn't work in Mobile Safari.
有没有人知道这个函数是否有可靠的替代方案? Android的浏览器似乎支持它很好,Safari桌面应用程序也支持onbeforeunload事件而没有问题。
Does anyone know if there's a reliable alternative to this function? Android's browser appears to support it just fine, and the Safari desktop application also supports the onbeforeunload event without issue.
推荐答案
我看到了这是一个老问题,但我最近遇到了这个问题。
I see that it's an old question, but i faced this problem recently.
我正在使用 window.unload
并且它有效在ios浏览器中很好(尽管如果你看看 Apple文档似乎已被弃用,他们建议使用 document.pagehide
)
I'm using window.unload
and it works fine in ios browsers (although if you look at Apple documentation it seems to be deprecated and they recommend to use document.pagehide
)
这篇关于有没有办法在Mobile Safari for iOS设备上使用window.onbeforeunload?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!