【问题标题】:Warning Message Popup警告消息弹出
【发布时间】:2015-08-07 15:24:36
【问题描述】:

这里我有一个网页,比如 create。突然,如果我单击其他选项卡需要显示警告消息,例如肯定要离开

这是我的代码:

<script type="text/javascript" language="javascript">

window.addEventListener("beforeunload", function (e) {

var confirmationMessage = 'It looks like you have been editing something.';

confirmationMessage += 'If you leave before saving, your changes will be lost.';

(e || window.event).returnValue = confirmationMessage;
return confirmationMessage;

});</script> 

但是我的问题是,如果我填写所有字段并提交,我得到了你想要离开上述代码的问题。只有当我单击其他页面或其他选项卡时,我才需要收到警告消息

请帮忙...

提前致谢

【问题讨论】:

    标签: jquery warnings message


    【解决方案1】:

    无论页面如何卸载,无论是按钮单击、选项卡还是任何链接,都将调用beforeunload 事件。要检查特定元素,您应该使用这些元素的 onClick 事件。

    【讨论】:

      猜你喜欢
      • 2011-06-06
      • 1970-01-01
      • 2012-08-22
      • 2013-06-06
      • 1970-01-01
      • 2016-02-24
      • 1970-01-01
      • 2021-01-19
      • 1970-01-01
      相关资源
      最近更新 更多