onBeforeUnload not working correctly for Chrome

烈酒焚心 提交于 2019-11-29 01:49:41

You're not doing anything wrong. Google has decided to do what Mozilla did and not allow you to show a custom message anymore. It took effect in Chrome 51.

You still need to return something to trigger the built-in dialog, but you're no longer allowed to determine what that dialog says.

Here's the BugZilla entry where Mozilla decided to do it in Firefox.

Here's the Chrome issue where Google decided to do it in Chrome.

*(The new Chrome 51 behavior was reported as a bug, but naturally it was closed within hours as it's by design.)

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