?
Solved

How stop event onBeforeUnload in Javascript.

Posted on 2005-04-01
4
Medium Priority
?
1,743 Views
Last Modified: 2008-02-07
In my application, i need to stop the event onBeforeUnload  when tu user press 'X' to close.
I want use my own "CloseWindow()" method.
I don't want to see the Window Dialog when the "return" is set.
I want to stop the event before to see this dialog.

For exemple:

function window_onunload()
{
   // DO SOMETHING TO STOP THIS EVENT
   myCloseWindow();
}

Any solutions are welcomes
Please, help!

Thanks
Sebastien



0
Comment
Question by:scarri
[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
4 Comments
 
LVL 25

Accepted Solution

by:
James Rodgers earned 252 total points
ID: 13683953
i'm pretty sure onBeforeUnload is IE only, but you could try this


document.onbeforeunload=function myFunc(){return false}
0
 
LVL 29

Assisted Solution

by:rdivilbiss
rdivilbiss earned 248 total points
ID: 13684720
The cross browser comand you are looking for is (traditional)

window.onunload = myCloseWindow();

In the more advance W3C Dom model (not widely supported) this would be,

window.addEventListener ('unload',myCloseWindow(),false);

http://www.quirksmode.org/js/events_compinfo.html

It is not possible to cancel the unloading of the page.  You can only specify the event handler to be used.

And of course, none of this works if the browser has JavaScript disabled.

Good Luck with your project.
Rod

0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Australian government abolished Visa 457 earlier this April and this article describes how this decision might affect Australian IT scene and IT experts.
CTAs encourage people to do something specific to show interest in your company, product or service. Keep reading to learn why CTAs should always be thought of as extremely important, albeit small, sections of websites.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
Suggested Courses

752 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