Re: Overriding onBeforeUnload dialog message
Quote:
Originally Posted by PeejAvery
Yes, it does. The return is only on the event handle itself not the rest of the onBeforeUnload commands.
I have done this code in IE, Firefox, and Safari. It works.
I'm not sure what you've done to manage this, but...
1) JavaScript executed in HTML event attributes is procedural just like all other JavaScript, and a return statement will cancel any following code.
2) Your code does not work. Running a return false statement in onbeforeunload followed by a call to another function will result in a question whether I want to leave the page with no custom message in Firefox 2, and "false" as the custom message in Internet Explorer 7. It doesn't work at all in other browsers because they do not support onbeforeunload.
Blocking users from leaving a page is a tricky area because it could be used in harmful ways. Firefox and Internet Explorer seem to allow the programmer to get the user to confirm leaving the page once using the onbeforeunload event, however, and here's how you use it:
Code:
<body onbeforeunload="return 'Leaving the page will result in a loss of work.'">
The browser will add some of its own text to clarify to the user what is happening.
Re: Overriding onBeforeUnload dialog message
Welcome to the forums rsarun. Please remember that when you have a question, to create a new thread instead of posting on somebody else's problem. The thread you posted in is 1.5 years old.
Re: Overriding onBeforeUnload dialog message
Im having same problems... Ive tried everything! Plz help!
P.S. Welles, youve posted on a lot of forums... have u got the answer yet?
Re: Overriding onBeforeUnload dialog message
Welcome to the forums, skylord5816. Please remember to create a new thread when you have a problem. Please don't post on somebody else's.