Close window without messagebox

S

Steven Malcolm

Hello there

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


Steven
 
S

Stuart Palmer

Only if it's not the last main browser window i.e not a popup.

I believe the answer is no.

Stu
 
S

Silvio Bierman

Steven Malcolm said:
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
 
M

Michael Winter

[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
 
R

Richard Cornford

Michael said:
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.
 
R

Randy Webb

Michael said:
[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.
 
S

Steven Malcolm

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
 
S

Steven Malcolm

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
 
R

Randy Webb

Steven said:
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.
 

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,764
Messages
2,569,564
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top