Robert Granlund
asked on
beforeunload Custom message in FF and Chrome
I know you can add a custom message to the alert box on "beforeunload" in IE but I can't find how to do it with FF or Chrome. Is this a functionality of the browser that disallows this or is there a work around?
This page http://www.w3schools.com/jsref/event_onbeforeunload.asp says it is supported in all browsers though it may be how you are coding it.
ASKER
@dave if you go to that page and then "try It Yourself" you will see that it does not work in Chrome: http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_onbeforeunload_html
Works just fine from here with Chrome in both XP and Win7.
ASKER
It won't return a custom message for me.
The demo page works fine. Show me the code you're trying to use.
ASKER
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script>
window.onbeforeunload = function() { return "text"; }
</script>
firefox doesn't show the custom message
You're right. See here: https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload
ASKER
So, from that article does it mean it is not possible?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
That says that Firefox will not display the message.