Urgent How to prevent that Internet Explorer is closed

C

Clemens Ortwickler

Hello

Is it possible with JavaScript to prevent that a User is closing the
Internet Explorer? Because it is important for me that the User pushes the
cancel Button of this webapplication how can i do this?

Thanks for your help
 
L

Lasse Reichstein Nielsen

Clemens Ortwickler said:
Is it possible with JavaScript to prevent that a User is closing the
Internet Explorer? Because it is important for me that the User pushes the
cancel Button of this webapplication how can i do this?

You can't. Redesign your application.
Will clicking your cancel button make a difference if the user isn't
connected to the internet any more?

You can *try* using the window.onunload handler. However, that also
triggers if the user tries to navigate away from the window, so it's
not your best guess. You should also expect the page to disappear,
so don't start anything that takes time in the handler. If really
desperate, you can open a new window (but expect every popup-blocker
out there to try to stop it).

/L
 
M

Michael Winter

Clemens Ortwickler wrote on 25 Nov 2003:
Hello

Is it possible with JavaScript to prevent that a User is closing
the Internet Explorer? Because it is important for me that the
User pushes the cancel Button of this webapplication how can i
do this?

I would really hope not: pop-up writers would have a field day with
that.

What you might be able to do (depending on what happens when the
cancellation occurs) is use the onunload intrinsic event to perform
whatever action the user is supposed to. If you're trying to write a
cookie or something similar, it should be fine. However, if it
involves navigating to another page, it won't help.

Mike
 
C

Clemens Ortwickler

You can't. Redesign your application.
Will clicking your cancel button make a difference if the user isn't
connected to the internet any more?

Thats very bad damn.... It is a local application so it doesn't matter. I
send HTTP Request to my Application and there should be a Request when you
click on the okay button the cancel button and when you close the Browser.
So if I use the unload method and i push the okay button i got 2 Requests
one for the unload handler and one for the okay button...

thats bad really bad but nevertheless thanks for your help!
 
M

Michael Winter

Clemens Ortwickler wrote on 25 Nov 2003:
Thats very bad damn.... It is a local application so it doesn't
matter. I send HTTP Request to my Application and there should
be a Request when you click on the okay button the cancel button
and when you close the Browser. So if I use the unload method
and i push the okay button i got 2 Requests one for the unload
handler and one for the okay button...

thats bad really bad but nevertheless thanks for your help!

You could have onclick handlers on the two buttons set a global that
the onunload event checks. If it's set, the onunload exits without
doing anything, and if not it does it's work. However, I'd take Mr
Nielsen's advice and find a new approach.

Mike
 
D

David Leverton

Clemens said:
Hello

Is it possible with JavaScript to prevent that a User is closing the
Internet Explorer? Because it is important for me that the User pushes the
cancel Button of this webapplication how can i do this?

Thanks for your help

<strong>
Warning: Do not close this window! If you wish to
cancel the process, please click the "Cancel" button.
</strong>

Simple, and works with any browser.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top