• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 893
  • Last Modified:

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?
0
rgranlund
Asked:
rgranlund
  • 5
  • 4
  • 2
1 Solution
 
Dave BaldwinFixer of ProblemsCommented:
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.
0
 
rgranlundAuthor Commented:
@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
0
 
Dave BaldwinFixer of ProblemsCommented:
Works just fine from here with Chrome in both XP and Win7.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
rgranlundAuthor Commented:
It won't return a custom message for me.
0
 
Dave BaldwinFixer of ProblemsCommented:
The demo page works fine.  Show me the code you're trying to use.
0
 
rgranlundAuthor Commented:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script>
window.onbeforeunload = function() { return "text"; }
</script>

Open in new window

0
 
David Johnson, CD, MVPOwnerCommented:
firefox doesn't show the custom message
0
 
Dave BaldwinFixer of ProblemsCommented:
0
 
rgranlundAuthor Commented:
So, from that article does it mean it is not possible?
0
 
David Johnson, CD, MVPOwnerCommented:
it is a function of the browser only IE and Edge will show the custom message.
0
 
Dave BaldwinFixer of ProblemsCommented:
That says that Firefox will not display the message.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 5
  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now