简体   繁体   English

用户单击Web浏览器窗口中的关闭按钮时,jQuery确认框

[英]jquery confirm box when user hit the close button in web browser's window

Is it possible to implement the same functionality as Javascript window.confirm() Box with jquery Modal Dialog Box when user hits the Web Browser's close button or leave the page or reload the page. 当用户单击Web浏览器的关闭按钮或离开页面或重新加载页面时,是否可以实现与Javascript window.confirm()Box相同的功能。

//////javascript code//////


sessionStorage["isTrue"] = false;
$(".PassReqNotes,.datePassed1").change(function () {
    sessionStorage["isTrue"]= true;
});
$(window).bind('beforeunload', function (event) {
    event.preventDefault();
    var sessionValue = sessionStorage["isTrue"].toLocaleString();
    if (sessionValue == "true") {
        isTrue = false;
        sessionStorage["isTrue"] = null;
        //return 'If you leave page, You may lose some changes';
       return window.confirm = dialog();
    }
});



function dialog(event) {
    $("#dialog-confirmPassReq").removeClass('hide').dialog({
        resizable: false,
        modal: true,
        title: "<div class='widget-header'><h4 class='smaller'><i class='ace-icon fa fa-exclamation-triangle red'></i> Delete Photo?</h4></div>",
        title_html: true,
        buttons: [
            {
                html: "<i class='ace-icon fa fa-trash-o bigger-110'></i>&nbsp; ok",
                "class": "btn btn-danger btn-xs btnDeleteActivityPhoto",
                click: function () {
                    $(this).dialog("close");
                    return true;
                }
            },
            {
                html: "<i class='ace-icon fa fa-times bigger-110'></i>&nbsp; Cancel",
                "class": "btn btn-xs",
                "id": "btnClosePassReq",
                click: function () {
                    $(this).dialog("close");
                    return false;
                }
            }
        ]
    });
}
window.onbeforeunload = function() {
    //your code
};

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 单击浏览器/标签关闭按钮时的确认框 - Confirm box when browser/Tag close button clicks 当用户按下浏览器的后退按钮时关闭Jquery对话框 - Close Jquery dialog when the user presses browser's back button 关闭浏览器窗口之前的javascript确认对话框 - javascript confirm dialog box before close browser window 当用户单击以关闭浏览器时,JavaScript确认触发(但单击刷新按钮时,则不触发) - JavaScript confirm to fire when user clicks to close their browser (but not when they click the refresh button) 用户尝试刷新/关闭/导航到另一个网页时显示确认对话框 - Displaying a confirm dialog box when the user tries to refresh/close/navigate to another web page 浏览器后退按钮上的确认框 - Confirm box on browser back button Javascript - 确认框以在用户单击退出按钮时重定向用户 - Javascript - Confirm box to redirect user when they click on exit button 如何从JQuery UI对话框中的按钮关闭窗口 - How to close a window from button in JQuery UI dialog box 如何检查何时触发浏览器窗口进行加载/重新加载/后退/前进并在jquery或javascript中关闭? - How to check when browser’s window is triggered for load/reload/backward/forward and close in jquery or javascript? 用jQuery花式框替换默认浏览器确认 - replace default browser confirm with jQuery fancy box
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM