469,587 Members | 2,134 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,587 developers. It's quick & easy.

Close window without messagebox

Hello there

Is it possible to close a window without the messagebox coming up asking if
you really want to close the window?
Steven
Jul 20 '05 #1
9 2442
Only if it's not the last main browser window i.e not a popup.

I believe the answer is no.

Stu

"Steven Malcolm" <mi***********@ozemail.com.au> wrote in message
news:9A***************@nnrp1.ozemail.com.au...
Hello there

Is it possible to close a window without the messagebox coming up asking if you really want to close the window?
Steven

Jul 20 '05 #2

"Steven Malcolm" <mi***********@ozemail.com.au> wrote in message
news:9A***************@nnrp1.ozemail.com.au...
Hello there

Is it possible to close a window without the messagebox coming up asking if you really want to close the window?
Steven


Depends. Most browsers will not let you do this, IE (at least the more
recent versions) will. To do it in IE use:

window.opener = window;
window.close();

IE seems to conclude that when a window has an opener it is not a top-level
window. This could break in any future version naturally but for now you can
save some users some trouble.

Silvio Bierman
Jul 20 '05 #3
On Fri, 5 Mar 2004 11:23:40 +0100, Silvio Bierman <sb******@idfix.nl>
wrote:

[snip]
IE seems to conclude that when a window has an opener it is not a
top-level window. This could break in any future version naturally
but for now you can save some users some trouble.


An intentionally introduced security vulnerability? What on Earth
possessed Microsoft to do this? JavaScript "developers" that complained
they couldn't close browser windows at their discretion, even when the
user might not want it to happen?

Mike

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 20 '05 #4
Michael Winter wrote:
Silvio Bierman wrote:
[snip]
IE seems to conclude that when a window has an opener it
is not a top-level window. This could break in any future
version naturally but for now you can save some users some
trouble.


An intentionally introduced security vulnerability? What
on Earth possessed Microsoft to do this? ...

<snip>

It is not so much introduced, more as yet unpatched. IE browsers (and a
fair number of others) have suffered from it for years. It doesn't get
publicised much on this group because rather than saving "users some
trouble", closing the users browser without their consent destroys
everything it continued, possibly including their browsing history,
session cookies, partly filled in form information, etc. So in reality,
predictably causing the user trouble. The people who ask the question
don't understand web browsers sufficiently to appreciate the harm such
an action can do, else they would never think such a thing was a god
idea.

The practical upshot of any wide dissemination of the hack, and its use
by inconsiderate web authors, will be that content-inserting proxies
will be distributed with built in filters to jump on either references
to the - window.close - method or the - opener - property. Moving
cross-window interaction even further into the realm of "too unreliable
to consider for Internet use". There are no shortage of javascript
authors who never consider the impact of their actions on users,
themselves or browser scripting as a task; whiteness the pop-up window.

Richard.
Jul 20 '05 #5
Michael Winter wrote:
On Fri, 5 Mar 2004 11:23:40 +0100, Silvio Bierman <sb******@idfix.nl>
wrote:

[snip]
IE seems to conclude that when a window has an opener it is not a
top-level window. This could break in any future version naturally
but for now you can save some users some trouble.

An intentionally introduced security vulnerability? What on Earth
possessed Microsoft to do this? JavaScript "developers" that complained
they couldn't close browser windows at their discretion, even when the
user might not want it to happen?

Mike


Search the archives for "The unconditional truth" and you will find a
partial list of browsers that have that "feature" and it is far from
limited to Microsoft.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/
Jul 20 '05 #6

Thanks for your answer, but excuse my ignorance, but I know next to
nothing about javascript.

How do I actually use

window.opener = window;
window.close();
Thanks
Steven
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #7
Thanks for your reply.

The reason I need to be able to close the web browser window is this.

I am writing a database at work which will work of a touchscreen at the
reception desk, and be used as a check-in/check-out system. Part of
this is that new visitors are taken through a short induction, which is
in the form of html pages(and I cannot change them to anything else),
and at the end of the presentation I need to be able to close the
browser and return to the database.

Thanks
Steven

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #8
Steven Malcolm wrote:
Thanks for your answer, but excuse my ignorance, but I know next to
nothing about javascript.

How do I actually use

window.opener = window;
window.close();


From your other reply, you are working in an intranet environment and
as such, you have more control over what browser is used. If you can
modify the last .html in the intro course, then you add the above
snippet in the last page in a script block.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/
Jul 20 '05 #9
On Fri, 5 Mar 2004 06:40:50 -0000, "Stuart Palmer"
<st**************@ntlworld.com> wrote:
Only if it's not the last main browser window i.e not a popup.


Or _blank ...

--

find clausen
http://www.photopress.dk
Jul 20 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by John H. | last post: by
3 posts views Thread by s-galit | last post: by
4 posts views Thread by PawelR | last post: by
1 post views Thread by Alpha | last post: by
2 posts views Thread by John H. | last post: by
7 posts views Thread by mg | last post: by
5 posts views Thread by Nicola Farina | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.