By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,825 Members | 1,708 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,825 IT Pros & Developers. It's quick & easy.

Urgent How to prevent that Internet Explorer is closed

P: n/a
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
Jul 20 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
"Clemens Ortwickler" <er*****@gmx.at> writes:
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
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2

P: n/a
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

--
Michael Winter
M.******@blueyonder.co.uk.invalid (remove ".invalid" to reply)
Jul 20 '05 #3

P: n/a
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!
Jul 20 '05 #4

P: n/a
Clemens Ortwickler wrote on 25 Nov 2003:
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!


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

--
Michael Winter
M.******@blueyonder.co.uk.invalid (remove ".invalid" to reply)
Jul 20 '05 #5

P: n/a
Clemens Ortwickler wrote:
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.

Jul 20 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.