Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/275.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript onbeforeunload不适用于Firefox_Javascript_Php_Firefox - Fatal编程技术网

Javascript onbeforeunload不适用于Firefox

Javascript onbeforeunload不适用于Firefox,javascript,php,firefox,Javascript,Php,Firefox,我需要在关闭浏览器时弹出一条消息。我在这个网站上找到了很多解决方案。虽然下面的代码是经过建议和验证的,但它适用于Chrome和Opera,但不适用于Firefox。我在执行中有什么遗漏吗? 我需要帮助。提前谢谢 <html> <body> <script type="text/javascript"> window.onbeforeunload = function (e) { var message = "Message to Show", e = e ||

我需要在关闭浏览器时弹出一条消息。我在这个网站上找到了很多解决方案。虽然下面的代码是经过建议和验证的,但它适用于Chrome和Opera,但不适用于Firefox。我在执行中有什么遗漏吗? 我需要帮助。提前谢谢

<html>
<body>
<script type="text/javascript">
window.onbeforeunload = function (e) {
var message = "Message to Show",
e = e || window.event;

if (e) {
e.returnValue = message;
}

return message;
};
</script>
</body>
</html>

window.onbeforeunload=函数(e){
var message=“要显示的消息”,
e=e | | window.event;
如果(e){
e、 返回值=消息;
}
返回消息;
};

您试过了吗?试过了。但是Firefox没有结果我不认为Firefox允许这样的自定义消息那么解决方案是什么呢?如何弹出消息?
在Firefox4及更高版本中,返回的字符串不会显示给用户。相反,Firefox显示字符串“此页面要求您确认是否要离开-您输入的数据可能无法保存。”