Answers for "alert onbeforeunload form page change"

2

javascript leave page warning

window.addEventListener("beforeunload", function (e) {
    var confirmationMessage = 'It looks like you have been editing something. '
                            + 'If you leave before saving, your changes will be lost.';

    (e || window.event).returnValue = confirmationMessage; //Gecko + IE
    return confirmationMessage; //Gecko + Webkit, Safari, Chrome etc.
});
Posted by: Guest on May-29-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language