FAQ Topic - How do I close a window and why does it not work on the first one?

F

FAQ server

-----------------------------------------------------------------------
FAQ Topic - How do I close a window and why does it not work on the first one?
-----------------------------------------------------------------------

Use `` windowRef.close() '', where windowRef is a window object
reference, such as window, top, parent, self, or a reference
obtained from the window.open() method. You can only close
windows opened by scripts, no others.

http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/close_0.asp

http://docs.sun.com/source/816-6408-10/window.htm#1201822


===
Postings such as this are automatically sent once a day. Their
goal is to answer repeated questions, and to offer the content to
the community for continuous evaluation/improvement. The complete
comp.lang.javascript FAQ is at http://www.jibbering.com/faq/.
The FAQ workers are a group of volunteers.
 
R

Randy Webb

FAQ server said the following on 8/26/2006 7:00 PM:
-----------------------------------------------------------------------
FAQ Topic - How do I close a window and why does it not work on the first one?
-----------------------------------------------------------------------

Use `` windowRef.close() '', where windowRef is a window object
reference, such as window, top, parent, self, or a reference
obtained from the window.open() method. You can only close
windows opened by scripts, no others.

That statement is about 20% true if it is that high a percentage.
 
L

-Lost

Randy said:
FAQ server said the following on 8/26/2006 7:00 PM:

That statement is about 20% true if it is that high a percentage.

Why is that? And why has the FAQ entry gone so long without change (on
this entry)?

(Note, I did not mean that to sound as if I were complaining it was
taking too long.)
 
L

-Lost

Randy said:
-Lost said the following on 4/23/2007 11:41 PM:

Because at the time that I wrote that (8 months ago), I could close
about 80% of windows that weren't opened with JS and the user couldn't
stop me.


At the time I made my post, I had nothing to do with editing the FAQ and
I doubt very seriously you would have gotten Richard to change it. And
the chances of me including the security flaw to get around it are 0%.
And now, about half of them have been closed up in IE, FF and Opera so
there isn't a whole lot of point in putting it in the FAQ.


Wait another 5 years and the FAQ probably still won't be changed to
include any way to annoy users by closing windows.

Sorry to hop on an old thread again, but I was wondering something.

You said that in times gone by you could close the majority of browsers.
I tested a wee bit of code and was wondering what drawbacks it had.
However, I do not wish to post it if it is a "security flaw."

I'd like to ask about it, how effective it is and whatnot, but again, I
am not posting something someone could use maliciously.

Can I possibly e-mail (a regular here) someone the code and get a
response? Or what should I do? Just post it?
 
L

-Lost

Randy said:
-Lost said the following on 5/21/2007 11:51 PM:

Any script that can close a window that script didn't open is exploiting
a security flaw :)


Email it to the address in the FAQ for me. Put FAQ in the subject line
as that address gets about 30 spams a day and the FAQ will keep me from
getting trigger happy.

<URL: http://jibbering.com/faq/index.html#FAQ5_2>

The way a browser tells whether a script opened the window was by
checking the window.opener property. In IE6 (and prior) and some earlier
FF and Opera you could set the window.opener property yourself thereby
allowing you to close the window.

Another flaw that I have not tested in a while was that if a window was
opened via a link with a target attribute (target="someWindow") then the
child window could close itself with window.close() even though script
didn't open the window. You could even close it from the parent in IE
for a little while - someWindow.close() - even if it was opened via a
targeted link.

E-mail sent.
 

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,770
Messages
2,569,584
Members
45,076
Latest member
OrderKetoBeez

Latest Threads

Top