Javascript 模式内未保存的信息提示用户在退出模式前保存

Javascript 模式内未保存的信息提示用户在退出模式前保存,javascript,jquery,asp.net,modal-dialog,Javascript,Jquery,Asp.net,Modal Dialog,我有一个情态动词 我想以这样的方式编写脚本:当用户点击“取消”或“退出”时,在文本框中输入任何信息时,它会提示用户保存未保存的信息 我还需要弄清楚如何默认“添加/编辑执行信息”按钮,我使用了此方法:$(this).closest('.ui dialog').find('.ui dialog buttonpane button:eq(0')).focus();要聚焦按钮,但当用户在文本框内单击,然后在文本框外单击时,按钮将取消聚焦 function ShowAddEditExecutive() {

我有一个情态动词

我想以这样的方式编写脚本:当用户点击“取消”或“退出”时,在文本框中输入任何信息时,它会提示用户保存未保存的信息

我还需要弄清楚如何默认“添加/编辑执行信息”按钮,我使用了此方法:$(this).closest('.ui dialog').find('.ui dialog buttonpane button:eq(0')).focus();要聚焦按钮,但当用户在文本框内单击,然后在文本框外单击时,按钮将取消聚焦

function ShowAddEditExecutive() {
        $("#addEditExecutive").dialog({
            modal: true,
            width: 800,
            appendTo: "form",
            open: function () {
      $(this).closest('.ui-dialog').find('.ui-dialog-buttonpane button:eq(0)').focus();
                 $(this).dialog("widget").find(".ui-dialog-titlebar").show();
                // Removes the do you want to leave this page dialog.
                window.onbeforeunload = null;
                // The two isplalines below are 2 different ways to ensure the 
                // background is completely grayed out if the modal is larger
                // then the page. The first was chosen so that the scroll
                // bars are not disabled.
                $('.ui-widget-overlay').css('position', 'fixed');
               //$('body').css('overflow', 'hidden');
              },
             buttons: {
                "Add/Edit Executive Information": function () {
                    $("[id*=btnAddEditExecutive]").click();
                 },
                "Cancel": function () {  
                        if (confirm("Are you sure you want to cancel ?")) {
                        //code if yes
                       $(this).dialog("close");
                    }
                 }
             },
        close: function (ev, ui) {
            // Ensures when you cancel that the values are not retained.
            $(this).remove();
            // The two lines below are 2 different ways to ensure the 
            // background is completely grayed out if the modal is larger
            // then the page. The first was chosen so that the scroll
            // bars are not disabled.
            $('.ui-widget-overlay').css('position', 'absolute');
            //$('body').css('overflow', 'inline');
        },

    });


    }
使用prompt()解决; Jquery命令