1

I'm tyring to catch the page leave event & check if the user have any unsaved changes. When I'm trying with alert, its working fine, the page reloading/leaving after I press the ok button on alert box as expected. But I'm trying to use kendo window for the confirmation with yes, no & cancel button. The problem is kendo window can't prevent the page from leaving or reloading, it just pops up & the page leaves almost immediately, leaving the user no time to respond to the window. I would like to stop the page from leaving until I press a button on kendo window.

Here is my code:

window.onbeforeunload = function (e) {

            if (changeStatus == 1)
            {
              //e.preventDefault();
              saveChangeWindow.open();
              //alert("test");
            }
        }; 

if I place the e.preventDefault(), then the page is waiting but an default message showing, which I don't actually need. Please help.

4

1 回答 1

2

简短的回答是你不能 - 显示一个窗口并等待用户选择一个按钮是与窗口的确认警报功能相比的异步操作。

于 2013-09-24T13:24:58.587 回答