G
G
goooooch2016-08-09 13:01:37
JavaScript
goooooch, 2016-08-09 13:01:37

Is the OnBeforeUnload event not supported by the latest versions of Chrome and FF?

If yes, how long ago? And can it be replaced with something? I need to display a message when the browser tab is closed.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mikhail Goryachkin, 2016-08-09
@abaddon65

Everything worked as it should. Here's a basic example from the documentation that works great in the latest versions of chrome and firefox:

window.onbeforeunload = function (evt) {
    var message = "Document 'foo' is not saved. You will lost the changes if you leave the page.";
    
    if (typeof evt == "undefined") {
        evt = window.event;
    }
    if (evt) {
        evt.returnValue = message;
    }
    return message;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question