Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

beforeunload Custom message in FF and Chrome

Posted on 2016-07-15
11
257 Views
Last Modified: 2016-07-30
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
Comment
Question by:rgranlund
  • 5
  • 4
  • 2
11 Comments
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 41713191
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
 
LVL 7

Author Comment

by:rgranlund
ID: 41713206
@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
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 41713228
Works just fine from here with Chrome in both XP and Win7.
0
How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

 
LVL 7

Author Comment

by:rgranlund
ID: 41713272
It won't return a custom message for me.
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 41713276
The demo page works fine.  Show me the code you're trying to use.
0
 
LVL 7

Author Comment

by:rgranlund
ID: 41713374
<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
 
LVL 80

Expert Comment

by:David Johnson, CD, MVP
ID: 41713457
firefox doesn't show the custom message
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 41713504
0
 
LVL 7

Author Comment

by:rgranlund
ID: 41713541
So, from that article does it mean it is not possible?
0
 
LVL 80

Accepted Solution

by:
David Johnson, CD, MVP earned 500 total points
ID: 41713553
it is a function of the browser only IE and Edge will show the custom message.
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 41713643
That says that Firefox will not display the message.
0

Featured Post

The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Do you come here a lot? Are you lazy like me and don't want to go through the "trouble" of having to click your Dock's Safari icon and then having to click your Experts Exchange Favorites bookmark to get here? Well then this article is for you.
This article offers some helpful and general tips for safe browsing and online shopping. It offers simple and manageable procedures that help to ensure the safety of one's personal information and the security of any devices.
The viewer will learn how to dynamically set the form action using jQuery.
Shows how to create a shortcut to site-search Experts Exchange using Google in the Chrome browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch the Search Engine Menu: In chrome, via you…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question