【问题标题】:Before saving the data Closing popup window show alert message?在保存数据之前关闭弹出窗口显示警报消息?
【发布时间】:2017-12-06 06:33:03
【问题描述】:

在单击保存按钮之前输入数据后的弹出页面中,用户尝试关闭弹出页面(X 标记)我想显示警报消息(您没有保存更改)。如果用户单击保存按钮,则无需显示警报消息。

使用 javascript 我该怎么做?

<script type="text/javascript">
 $(document).ready(function () {

     var unsaved = false;
     $('#Button1').click(function () {
         unsaved = true;
     });

     function unloadPage() {
         if (unsaved) {
             return "You have unsaved changes on this page.?";
         }
     }

     window.onbeforeunload = unloadPage;
 });

</script>

【问题讨论】:

标签: javascript alert


【解决方案1】:

使用下面的技术可能有用

      var is_template_save;
if (is_need_save == '0') {
    is_template_save = false;
} else {
    is_template_save = true;
}

window.onbeforeunload = function () {
    if (is_template_save) {
        return "Did you save your template?"
    }
}
function template_save() {
    is_template_save = false;
}
function template_unsave() {
    is_template_save = true;
}

希望有意义

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-17
    • 2013-02-26
    相关资源
    最近更新 更多