473,698 Members | 2,471 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

changing onbeforeunload

OK - I know the mantra, so let's be clear: I'm working on a web
application that we want to be able to simply warn the user that they
might lose data (or the current application state - it's .NET) if they
navigate away from the page using the Back button. I was thinking of
using onbeforeunload (which seems to work with IE, FF, and Netscape, but
not Opera & Safari - that is acceptable).

The problem is that if I define onbeforeunload, even without providing a
function (like: <body onbeforeunload= ""> ), I get that confirmation
dialog that says "Are you sure you want to navigate away from this page?"

I'd like to override that message, but I can't seem to find a way to do
it. Any thoughts?

(and please don't say "don't do it" - that isn't an option in this case)
May 8 '06 #1
3 6229
I have used "onbeforeunload " and I have face the similar problem that
we cant override the default message but then I tried to add my own
message and it worked...

<html>
<head>
<title>....
<script>
function alertWindowClos e(){
return ("Your Own Message Goes Here....")
}
</script>
</head>
<body onbeforeUnload= "return alertWindowClos e()">
</html>

Hope this might help you..
Rrds,
Jigar

May 10 '06 #2
me********@gmai l.com wrote:
I have used "onbeforeunload " and I have face the similar problem that
we cant override the default message but then I tried to add my own
message and it worked...

<html>
<head>
<title>....
<script>
function alertWindowClos e(){
return ("Your Own Message Goes Here....")
}
</script>
</head>
<body onbeforeUnload= "return alertWindowClos e()">
</html>

Hope this might help you..


When I do that, I end up with my message, which is followed by the
standard message. Having to give the user one message is bad enough - I
don't want to irritate them by forcing them through TWO messages...
May 10 '06 #3
FragMaster B
1 New Member
I have implemented something similar to mehtajigar@gmai l.com in an old IE only app. Not sure of the Mozilla equivalent (if there is one).

This method only gives me one prompt. And users can click "cancel" to NOT leave the page.

Expand|Select|Wrap|Line Numbers
  1. <script language="JavaScript" type="text/JavaScript">
  2. function ExitWarn(){
  3.     event.returnValue = "MSG TEXT HERE";
  4. }
  5. </script>
  6.  
  7. </head>
  8.  
  9. <body onbeforeunload="ExitWarn();">
  10.  
May 23 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
10562
by: lltaylor | last post by:
Hello, Currently I use an onbeforeunload method, to do call various tidy up methods when a user exits my web application - however I now need to add additional support, for users migrating to Sun's JVM. My understanding that the onbeforeunload call is a Microsoft one, and the net result of having it in a page used by a SUN JVM user is that the
6
23118
by: jennyw | last post by:
Hi, I'd like to use onbeforeunload to submit a form before leaving a page. This works in Firefox and IE. Safari, however, blithely ignores this. Does anyone know of a workaround for Safari? Or another way to do the same thing in Safari? (that is, intercept a request to leave the page). I tried Safari 2.02 on Tiger. Thanks!
4
10199
by: sowencheung | last post by:
the bug of onbeforeunload is so obvious! in IE 6 it will popup twice "sometimes" I am using the following code window.onbeforeunload = null; window.onbeforeunload = confirmExit; var executingPostBack = false;
8
7572
by: drewmania001 | last post by:
im currently using the following to prompt the user before navigating away from the page // add an unload event window.onbeforeunload = bunload; // function to prompt user function bunload(o){ return false; }
1
4113
by: David | last post by:
I am using a process to warn users when they leave a page that there have been changes made. I took the example directly from Microsoft example I found in searching for help on the event onbeforeunload. I have the event inside the BODY element in my aspx page and it seems to work just fine. However, I still get a flash of a page error in the lower left corner of my browser and the Visual Studio 2005 "souce" page shows the event name...
5
9699
by: allan.young | last post by:
Hi, When in gmail I'm composing a new email message and I bit the browser back button, I get a dialog that says "Your message has not been sent. Discard your message?" But if instead of clicking Back, I hit the Browser Close button, I get the above message, PLUS if I click "cancel" on that dialog, I get the following message 'Are you sure you want to navigate away from this page? Press "Cancel" to remain on this page. Press OK to...
1
108746
Frinavale
by: Frinavale | last post by:
Introduction I've seen many questions asked about how to disable the browser's back button and in the past I've replied with "it's simply not possible". It's not a good idea to disable the back button anyways, if the user ventures away from your page then they wouldn't have this button at their disposal. The main reason people ask how to control or disable the back button is because they have a need to control sensitive (and/or) dynamic web...
0
8683
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8609
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8901
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6528
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5862
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4371
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2336
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.