Solved

beforeunload Custom message in FF and Chrome

Posted on 2016-07-15
11
486 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
[X]
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
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 81

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 81

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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
This Micro Tutorial will demonstrate how nuggets on the Web are formatted by using Chrome Developer Tools. These tools would not only view the site's CSS but it can also modify it and save the CSS to use on your own site.

696 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