window.onbeforeunload in Chrome: what is the most recent fix?

Answer:

$(window).on('beforeunload', function() {
    var x =logout();
    return x;
});
function logout(){
        jQuery.ajax({
        });
        return 1+3;
}

A little mix and match, but it worked for me. The 1+3 makes sure that the logout function is being called (you’ll see 4 if it’s successful on the popup when you try to leave).

Leave a Comment