473,467 Members | 1,985 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

any alternate for OnBeforeUnload?

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;

function confirmExit()
{
if ( typeof executingPostBack != 'undefined' && !executingPostBack)
{
return 'Warning: Modified data has not been saved.' ;
}
}

In some cases, IE pops up it twice, for example, when we click a link
that contains "__doPostBack", onbeforeunload is fired the first time;
when the form is submitted, it is fired second time.

There is no way to work it around, because onbeforeunload is stupid, we
can't know whether the user clicks OK or Cancel.

I would like to use the following code with confirm so that I know
exactly what the user behaves

res = confirm("leaving?");
if (res==1)
{
alert("yes");
}
else
{
alert("no");
}

but I can't use this in onbeforeunload, because I can't stop it!
onbeforeunload always asks for something return, but if I return
anything, it will popup!

anyway, I hope someone understands my feeling.

is there any genius can help me out of this?
thanks!

Jun 6 '06 #1
4 10184
On 6 Jun 2006 12:08:17 -0700, so*********@gmail.com wrote:
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;

function confirmExit()
{
if ( typeof executingPostBack != 'undefined' && !executingPostBack)
{
return 'Warning: Modified data has not been saved.' ;
}
}

In some cases, IE pops up it twice, for example, when we click a link
that contains "__doPostBack", onbeforeunload is fired the first time;
when the form is submitted, it is fired second time.


The problem is the __doPostBack, and not the onbeforeunload, or FAQ
4.24

Jim.
Jun 6 '06 #2
i will have to say, it is a bug of IE at least

see

http://dbforums.com/showthread.php?t=622842

i agree if i change to href="#", it will work
but it's not possible. those code are generated by .net, and our system
is really huge, and whoever is going to use LinkButton must override
the prerender to modify the link, is it feasible in your opinion?

Jun 6 '06 #3
On 6 Jun 2006 12:36:06 -0700, so*********@gmail.com wrote:
i will have to say, it is a bug of IE at least
It's absolutely not a bug in IE, if you tell the UA to navigate to
javascript:X expect it to do it!
but it's not possible. those code are generated by .net, and our system
is really huge, and whoever is going to use LinkButton must override
the prerender to modify the link, is it feasible in your opinion?


Well you really should've considered all this when picking such a poor
quality framework, if it's incompatible, have it produce better code,
I understand webforms can do that.

Jim.

Jun 6 '06 #4
so*********@gmail.com wrote:
i will have to say, it is a bug of IE at least

see

http://dbforums.com/showthread.php?t=622842

i agree if i change to href="#", it will work
but it's not possible. those code are generated by .net, and our system
is really huge, and whoever is going to use LinkButton must override
the prerender to modify the link, is it feasible in your opinion?


The .NET programmers where I work do it all the time.
Jun 6 '06 #5

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

Similar topics

4
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...
6
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...
8
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...
1
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...
5
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...
1
dmjpro
by: dmjpro | last post by:
What is the alternate way to track the "onbeforeunload"? Please Help! Debasis Jana
1
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...
0
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 ...

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.