My javascript
makes a jquery ajax
call to the server to save the page fields. On the ajax success event I am invoking a window.location call to navigate to another webpage. The browser always displays a 'Leave site? Do you want to lose your changes' message when the navigation happens. I have tried various ways to suppress the message but they dont seem to work. I tried window.off
syntax which failed
$(window).off('beforeunload');
Then I went on to try the window eventlistener
as below which again failed to suppress the alert
window.addEventListener("beforeunload", function (event) {
event.preventDefault();
event.returnValue = '';
});
Are there any other ways to suppress the leave site message. I am using Chrome version 75.x