javascript事件onbeforeunload在mozila firefox中无法正常工作......? [英] Javascript event onbeforeunload is not working properly in mozila firefox ... ?

查看:73
本文介绍了javascript事件onbeforeunload在mozila firefox中无法正常工作......?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在关闭Firefox的标签/浏览器时显示确认弹出窗口,但它无法正常工作。我使用onbeforeunload的JavaScript事件,并使用下面的代码:





window.onbeforeunload = DetectBrowserExit;



函数DetectBrowserExit(){

返回'你确定退出';

}



我尝试过:



window.onbeforeunload = DetectBrowserExit;



函数DetectBrowserExit(){

返回'你确定退出';

}

I am trying to show the confirmation popup while close the tab/browser of firefox but it is not working . I am using onbeforeunload event of javascript and using the following code :


window.onbeforeunload = DetectBrowserExit;

function DetectBrowserExit() {
return 'Are you sure to exit';
}

What I have tried:

window.onbeforeunload = DetectBrowserExit;

function DetectBrowserExit() {
return 'Are you sure to exit';
}

推荐答案

请停止尝试。



onbeforeunload是一种清理localStorage或cookies的方法。

或者可以调用服务器脚本删除会话数据。



但是阻止用户界面关闭你的页面。



大多数浏览器都不允许你这样做,如果他们这样做,他们将来就会停止这样做。



它被认为是有害的
Please stop trying.

The onbeforeunload is a way to clean up localStorage or cookies.
Or maybe call a server script to delete session data.

But not the block the UI from closing you're page.

Most browsers will not allow you to do this and if they do, they stop doing it in the future.

It's considered harmfull


这篇关于javascript事件onbeforeunload在mozila firefox中无法正常工作......?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆