Is the onbeforeunload event not supported on iPhone?

和自甴很熟 提交于 2019-11-26 17:23:51

问题


So, I've got a handy little bit of functionality in place in a jQuery Mobile app that lets the user know if he/she is navigating away from the page, as this will trigger a log off. In simplified form:

$(window).bind('beforeunload', function() {
  return "Navigating away from this page will log you off. Are you sure you want to continue?";
});

$(window).unload(function() {
  logoff();
});

This works just great in both Safari and Chrome on my laptop. However, it doesn't appear to work on the iPhone simulator.

Does the mobile browser included in iOS (I know it's Safari, but presumably a different version) simply not support the beforeunload event? Is this true in general for mobile devices (in particular, Android)?


回答1:


The iPhone indeed does not support onbeforeunload

This question has a possible workaround: Is there any way to use window.onbeforeunload on Mobile Safari for iOS devices?



来源:https://stackoverflow.com/questions/6903457/is-the-onbeforeunload-event-not-supported-on-iphone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!