如何在js中更改页面加载对话框的值? [英] how to change value of page load dialog box in js?
问题描述
Hello Team
这是我的代码,但不支持firefox
var myEvent = window.attachEvent || window.addEventListener;
var chkevent =(window.attachEvent)?onbeforeunload:beforeunload;
myEvent(chkevent,function(e){// For> = IE7,Chrome,Firefox
window.onbeforeunload = null;
var confirmationMessage ='Rajeev Rahi'; //空格
(e || window.event).returnValue = confirmationMessage;
return confirmationMessage;
});
Rajeev Rahi正在显示当我刷新铬而不能在firefox中工作时
实际上我想要更改刷新弹出窗口。
Hello Team
this is my code but not support in firefox
var myEvent = window.attachEvent || window.addEventListener;
var chkevent = (window.attachEvent) ?onbeforeunload : beforeunload;
myEvent(chkevent, function(e) { // For >=IE7, Chrome, Firefox
window.onbeforeunload = null;
var confirmationMessage = 'Rajeev Rahi'; // a space
(e || window.event).returnValue = confirmationMessage ;
return confirmationMessage ;
});
Rajeev Rahi is showing when i refresh on chrom but not work in firefox
Actually i want change in refresh pop-up.
推荐答案
你不能。我昨天遇到了这个问题,结果发现这是一个安全功能:
错误588292 - 删除站点提供的beforeunload和onunload对话框文本,并改进按钮文本 [ ^ ]
很明显为什么Mozilla认为这是一个安全问题,当其他每个浏览器都支持它时,我不知道知道。
唯一的解决方法是在每个元素的click事件中显示一条消息,导致页面卸载。它既凌乱又脆弱,但它是显示自定义消息的唯一方式。
You can't. I ran into this problem yesterday, and it turns out it's a "security feature":
Bug 588292 - Remove site-supplied text for beforeunload and onunload dialogs, and improve button text [^]
Quite why Mozilla think it's a security problem, when every other browser supports it, I don't know.
The only workaround is to display a message in the "click" event of every element which would cause the page to unload. It's messy and fragile, but it's the only way to display a custom message.
这篇关于如何在js中更改页面加载对话框的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!