如何在关闭窗口时从确认框中删除自定义消息 [英] How to remove custom message from confirmation box while closing window
问题描述
我正在使用自定义代码在用户尝试关闭jquery(MVC 3代码)中的窗口时抛出确认框。如下面的代码我正在使用
I am using custom code to throw confirmation box while user try to close window in jquery(MVC 3 code). as below code i am using
var chkevent = window.attachEvent? 'onbeforeunload':'beforeunload';
  var myEvent = window.attachEvent || window.addEventListener;
  myEvent(chkevent,function(e){
var confirmationMessage ='这是消息'; //空格
(e || window.event).returnValue = confirmationMessage;
return confirmationMessage;
});
var chkevent = window.attachEvent ? 'onbeforeunload' : 'beforeunload';
var myEvent = window.attachEvent || window.addEventListener;
myEvent(chkevent, function (e) {
var confirmationMessage = 'This is message'; // a space
(e || window.event).returnValue = confirmationMessage;
return confirmationMessage;
});
我只想要彩色圆圈信息,我不想要的上下信息。
i just want colored circle message ,up and down message i do not want.
请更新我如何操作?
谢谢
推荐答案
根据关于这个主题的很多文章,你无法自定义这个浏览器的特殊对话框。如果您确定它是离开页面是安全的。
According to many articles on this topic, you cannot customize this special dialog of browsers. You can only skip it, by returning an undefined value (simple ‘return;’ or ‘return undefined;’), if you have determined that it is safe to leave the page.
但如果您有按钮或链接,您可以单独处理它们并显示您的自定义对话框或使用
确认功能。当用户单击"后退"按钮或关闭浏览器等时,应保留 beforeunload 。
But if you have buttons or links, you can handle them separately and display your custom dialog or use confirm function. The beforeunload should be kept for the case when the user click the Back button or close the browser etc.
这篇关于如何在关闭窗口时从确认框中删除自定义消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!