javascript - 有什么方法可以在退出firefox浏览器时显示自定义消息

标签 javascript html

我想要一个脚本,当它从 Firefox 浏览器中的页面退出时,它可以向用户显示自定义消息。即使在使用自定义消息后,Firefox 也会显示其默认消息,尽管 chrome 可以正确显示它。但我也想在 Firefox 中显示此自定义消息

 window.onbeforeunload = function() {

   return 'Are you sure.';
 }

最佳答案

看来他们故意禁用了它:https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload

In Firefox 4 and later the returned string is not displayed to the user. Instead, Firefox displays the string "This page is asking you to confirm that you want to leave - data you have entered may not be saved."

请参阅此相关问题以获取潜在的解决方法,但所有这些都非常困惑:

Firefox 4 onBeforeUnload custom message

关于javascript - 有什么方法可以在退出firefox浏览器时显示自定义消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32185577/

相关文章:

html - 垂直居中文本覆盖

php - html 页面上方的静态消息

javascript - 想要在 XUL 代码中恢复 javascript 函数的字符串

javascript - Node.js express路由POST请求空体,使用body-parser

javascript - session 日历 |如何处理在日历中显示的重叠 session ?

javascript - 未经直接许可估计用户的上传速度

html - 我需要将 div 最大宽度设置为设备宽度

javascript - 如何重写 jQuery 验证两次?

javascript - 显示数组中第一个值的函数,如果再次运行它,则显示数组中的第二个值

javascript - 如何使用 w3c 选项卡样式链接到特定选项卡