471,350 Members | 1,435 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,350 software developers and data experts.

Window close event

This is brobably a newbie question but is there anyway to actually stop a
windows close event and stop a user from exiting a page the wrong way.

I know you can use the onbeforeUnload to display a message buy is there
anyway of completely stopping a user from closing a window.

Thanks,

Tony.
Jul 23 '05 #1
2 1998
Tony Clarke wrote:
This is brobably a newbie question but is there anyway to actually stop a
windows close event and stop a user from exiting a page the wrong way.


No.

If there was, then Joe Evil could author a webpage which would consider
_any_ way to leave it as "the wrong way", as it is entirely unacceptable
that people who got a nasty popup should be able to get rid of the hard
core pornography advert in the middle of their screen.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Jul 23 '05 #2
"David Dorward" <do*****@yahoo.com> wrote in message
news:d2*******************@news.demon.co.uk...
Tony Clarke wrote:
This is brobably a newbie question but is there anyway to actually
stop a
windows close event and stop a user from exiting a page the wrong
way.


No.

If there was, then Joe Evil could author a webpage which would
consider
_any_ way to leave it as "the wrong way", as it is entirely
unacceptable
that people who got a nasty popup should be able to get rid of the
hard
core pornography advert in the middle of their screen.


Not only that, but how are you going to prevent me from reaching out and
hitting the power button on my computer using client-side JavaScript?

I'd imagine that having the computer shut down without doing any further
interaction with the Web server would most likely be considered "exiting
a page the wrong way".

Not to mention that http is stateless, which means once I've requested a
resource from the Web server, and that resource has been delivered, as
far as the Web server is concerned I already _have_ "exited the page"
(discounting session management).

Once you understand the stateless nature of http, you stop trying to
control the users' activities (because there is no way you can control
_everything_ they do) and you start writing your server-side code to
deal with _all_ possibilities (user hitting reload, user opening a new
window in the same session, user logging in and never logging out, etc).

--
Grant Wagner <gw*****@agricoreunited.com>
comp.lang.javascript FAQ - http://jibbering.com/faq
Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

19 posts views Thread by Darren | last post: by
2 posts views Thread by RJN | last post: by
5 posts views Thread by lindanr | last post: by
5 posts views Thread by jimmy | last post: by
15 posts views Thread by Mahernoz | last post: by
reply views Thread by XIAOLAOHU | last post: by

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.