문제

I have the following code which works quite well with browser when the user is closing the tab.

//Alert if quitting
safeExit = false;
function closeEditorWarning(){
    if(!safeExit){
        return 'Please remember to save and sync your changes'
    }
    safeExit = false;
}

window.onbeforeunload = closeEditorWarning;

We have previously tested this using the simple demo in CEF3, however it doesnt seem to execute when we ported the app to Node-webkit. Any help would be appreciated.

도움이 되었습니까?

해결책

You should wrap your call in a "on" event on the window.

safeExit = false;
win.on('close', function () {
    // show warning if you want
    this.close(safeExit);
});

Warning - the above code will go into an infinite loop, you can simply open the console and set safeExit to true to exit the program. I hope this helps!

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top