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

Window.close on IE7 & FF2 - beyond .opener= and .open

P: n/a
After considerable googling - I mean searching with Google(r) - I
could not find javascript on a button or <a href=... to close a
window in the latest versions of IE and FireFox.

There seemed to be two techniques for earlier versions. But the
window.opener='' ;window.close();
and the
window.open('','_parent','') ;window.close();

techniques do not work for me. I.e., I still get confirmation message
in IE7 and no change in FF2. Is that correct or did I do something
wrong?

Is there a way to do this at all in javascript (no ActiveX sendkeys)
in Firefox 2 and Safari? Or to get around the dialog box in IE7?

TIA

Feb 6 '07 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Toccoa wrote :
After considerable googling
I doubt this; you obviously did not search this newsgroup's past posted
messages on window.close().

- I mean searching with Google(r) - I
could not find javascript on a button or <a href=... to close a
window in the latest versions of IE and FireFox.
Open up a browser window and then look at the top right corner of the
window, on the titlebar. What do you see? Do you see a link or do you
see a command system button? Why should a link be able to close a
window? Isn't the default and normal action of a link to load a new
webpage (to replace current webpage with a new webpage) into the current
browser window?

Now, please tell me what's wrong with that "X" icon button on that
titlebar?

Why do you need to duplicate it with javascript? What's wrong with
default basic standard interface of a browser window? Why do you want to
control the user's browser window to the point that he will have to use
your javascript-dependent widget instead of his standard default close
button in the titlebar?

If you need an extra button, then ask yourself why an user would or
should prefer+trust your javascript-driven button to his browser window
basic standard close button.

Now, why can't you duplicate with javascript the Refresh button too? Why
not? And then the Back button. Why not duplicate the Forward button too?
Then the resize/restore button. And the minimize button.
There seemed to be two techniques for earlier versions. But the
window.opener='' ;window.close();
and the
window.open('','_parent','') ;window.close();

techniques do not work for me. I.e., I still get confirmation message
in IE7

'Invoking the window.close method on a window not opened with script
displays a confirmation dialog box. Using script to close the last
running instance of Microsoft Internet Explorer also opens the
confirmation dialog box.'
http://msdn.microsoft.com/workshop/a...asp?frame=true

I personally asked myself Microsoft to fix that bug in channel9 feedback
webpage

http://channel9.msdn.com/wiki/defaul...plorerSecurity

http://www.gtalbot.org/BrowserBugsSe...penedByJS.html

and to fix it for good in IE7. Leave IE7 windows alone! If web authors
should not abuse opening of window via script (unrequested
javascript-initiated opening of secondary window, popups), then they
shouldn't be able to close windows via script. It also has been the
perspective of Microsoft to warn users about script trying to close
their window so that they can grant or decline such actions so that they
would not lose history of visited urls.

and no change in FF2. Is that correct or did I do something
wrong?
A javascript-initiated window can be closed by close(); other windows
can not be by forced closed by javascript with close().

http://kb.mozillazine.org/about:config_entries#DOM..2A
Is there a way to do this at all in javascript (no ActiveX sendkeys)
in Firefox 2 and Safari? Or to get around the dialog box in IE7?
Stop coding links or buttons to close a window. Start accepting that you
are not the user. (S)He does not need your scripts to close his/her
browser windows.

Gérard
--
Using Web Standards in your Web Pages (Updated Dec. 2006)
http://developer.mozilla.org/en/docs...your_Web_Pages
Feb 6 '07 #2

P: n/a
Gérard Talbot wrote:
Toccoa wrote :
>After considerable googling

I doubt this; you obviously did not search this newsgroup's past posted
messages on window.close().

- I mean searching with Google(r) - I
>could not find javascript on a button or <a href=... to close a
window in the latest versions of IE and FireFox.

Open up a browser window and then look at the top right corner of the
window, on the titlebar. What do you see? Do you see a link or do you
see a command system button? Why should a link be able to close a
window? Isn't the default and normal action of a link to load a new
webpage (to replace current webpage with a new webpage) into the current
browser window?

Now, please tell me what's wrong with that "X" icon button on that
titlebar?

Why do you need to duplicate it with javascript? What's wrong with
default basic standard interface of a browser window? Why do you want to
control the user's browser window to the point that he will have to use
your javascript-dependent widget instead of his standard default close
button in the titlebar?

If you need an extra button, then ask yourself why an user would or
should prefer+trust your javascript-driven button to his browser window
basic standard close button.

Now, why can't you duplicate with javascript the Refresh button too? Why
not? And then the Back button. Why not duplicate the Forward button too?
Then the resize/restore button. And the minimize button.
>There seemed to be two techniques for earlier versions. But the
window.opener='' ;window.close();
and the
window.open('','_parent','') ;window.close();

techniques do not work for me. I.e., I still get confirmation message
in IE7


'Invoking the window.close method on a window not opened with script
displays a confirmation dialog box. Using script to close the last
running instance of Microsoft Internet Explorer also opens the
confirmation dialog box.'
http://msdn.microsoft.com/workshop/a...asp?frame=true
I personally asked myself Microsoft to fix that bug in channel9 feedback
webpage

http://channel9.msdn.com/wiki/defaul...plorerSecurity
http://www.gtalbot.org/BrowserBugsSe...penedByJS.html
and to fix it for good in IE7. Leave IE7 windows alone! If web authors
should not abuse opening of window via script (unrequested
javascript-initiated opening of secondary window, popups), then they
shouldn't be able to close windows via script. It also has been the
perspective of Microsoft to warn users about script trying to close
their window so that they can grant or decline such actions so that they
would not lose history of visited urls.

and no change in FF2. Is that correct or did I do something
>wrong?

A javascript-initiated window can be closed by close(); other windows
can not be by forced closed by javascript with close().

http://kb.mozillazine.org/about:config_entries#DOM..2A
>Is there a way to do this at all in javascript (no ActiveX sendkeys)
in Firefox 2 and Safari? Or to get around the dialog box in IE7?

Stop coding links or buttons to close a window. Start accepting that you
are not the user. (S)He does not need your scripts to close his/her
browser windows.
You're being a bit hard.

There do exist situations (in my opinion) where it would be appropriate
to allow javascript to close a window it didn't open but, as far as I
understand it, these situations constitute such a tiny minority and the
opportunity for misuse (of the technique) is too great to allow it
happen. That is, modern browser should not (and generally do not) allow
javascript to close a window it didn't open.

Andrew Poulos
Feb 6 '07 #3

P: n/a
Andrew Poulos said the following on 2/6/2007 12:11 AM:
Gérard Talbot wrote:
>Toccoa wrote :
<snip>
>>Is there a way to do this at all in javascript (no ActiveX sendkeys)
in Firefox 2 and Safari? Or to get around the dialog box in IE7?

Stop coding links or buttons to close a window. Start accepting that
you are not the user. (S)He does not need your scripts to close
his/her browser windows.

You're being a bit hard.
I disagree with you Andrew. The entire post wasn't a "bit hard", it was
too lenient. While there may be a .01% legitimate use for closing a
window you didn't open, the majority of the time there is no good reason
to close a window you didn't open.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Feb 6 '07 #4

P: n/a
In comp.lang.javascript message <Lf********************@telcove.net>,
Tue, 6 Feb 2007 07:45:41, Randy Webb <Hi************@aol.composted:
While there may be a .01% legitimate use for closing a window you
didn't open, the majority of the time there is no good reason to close
a window you didn't open.

That's not really significant.

What is significant is that, if it were possible, 99% of commercial
sites would set their pages to close all other windows. Given an
unguarded public resource, most businesses will exploit it to the limit
and attempt to control or monopolise it. And remember that the USA
claims to lead the world.

--
(c) John Stockton, Surrey, UK. ??*@merlyn.demon.co.uk Turnpike v6.05 MIME.
Web <URL:http://www.merlyn.demon.co.uk/- FAQish topics, acronyms, & links.
Check boilerplate spelling -- error is a public sign of incompetence.
Never fully trust an article from a poster who gives no full real name.
Feb 6 '07 #5

P: n/a
Dr J R Stockton said the following on 2/6/2007 1:52 PM:
In comp.lang.javascript message <Lf********************@telcove.net>,
Tue, 6 Feb 2007 07:45:41, Randy Webb <Hi************@aol.composted:
>While there may be a .01% legitimate use for closing a window you
didn't open, the majority of the time there is no good reason to close
a window you didn't open.


That's not really significant.
It's "not really significant" to say there there is no good reason to
close a window you didn't open? Ironic to say the least. It is very
significant.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Feb 8 '07 #6

P: n/a
In comp.lang.javascript message <rb********************@telcove.net>,
Wed, 7 Feb 2007 19:16:34, Randy Webb <Hi************@aol.composted:
>Dr J R Stockton said the following on 2/6/2007 1:52 PM:
>In comp.lang.javascript message <Lf********************@telcove.net>,
Tue, 6 Feb 2007 07:45:41, Randy Webb <Hi************@aol.composted:
>>While there may be a .01% legitimate use for closing a window you
didn't open, the majority of the time there is no good reason to close
a window you didn't open.
That's not really significant.

It's "not really significant" to say there there is no good reason to
close a window you didn't open? Ironic to say the least. It is very
significant.

You have an obnoxious habit of trimming that which should have been
quoted when it would have shown that you were just giving a knee-jerk
reaction without understanding what you did not quote. That's immature.

"There is no good reason" != "There is a bad reason"

Your reason is sound; once upon a time, it might have been important;
but it is overwhelmed into insignificance by the exposure of other-
window-closing as an opportunity that would nowadays be misused by the
ill-mannered - which, as you should have observed, will be the vast
majority of commercial sites.

--
(c) John Stockton, Surrey, UK. ??*@merlyn.demon.co.uk Turnpike v6.05 MIME.
Web <URL:http://www.merlyn.demon.co.uk/- FAQish topics, acronyms, & links.
Check boilerplate spelling -- error is a public sign of incompetence.
Never fully trust an article from a poster who gives no full real name.
Feb 8 '07 #7

P: n/a
Dr J R Stockton said the following on 2/8/2007 4:48 PM:
In comp.lang.javascript message <rb********************@telcove.net>,
Wed, 7 Feb 2007 19:16:34, Randy Webb <Hi************@aol.composted:
>Dr J R Stockton said the following on 2/6/2007 1:52 PM:
>>In comp.lang.javascript message <Lf********************@telcove.net>,
Tue, 6 Feb 2007 07:45:41, Randy Webb <Hi************@aol.composted:

While there may be a .01% legitimate use for closing a window you
didn't open, the majority of the time there is no good reason to close
a window you didn't open.
That's not really significant.
It's "not really significant" to say there there is no good reason to
close a window you didn't open? Ironic to say the least. It is very
significant.


You have an obnoxious habit of trimming that which should have been
quoted when it would have shown that you were just giving a knee-jerk
reaction without understanding what you did not quote. That's immature.
And you have an obnoxious habit of thinking you are the only one that
has a clue what is going on when it is quite often the opposite.

But, just for you, I will add obnoxious and immature to the list of
words that have been used to describe me. I thought TL was the only one
that did that on a regular basis but I see you have proven me wrong
about that one.
"There is no good reason" != "There is a bad reason"
Nobody said they were equal so I am not sure why - unless it is some
kind of perverse personal gratification you get from stating the obvious
- why you felt the need to point that out.
Your reason is sound;
Then why would you call it "not really significant"? Does that mean "It
is a sound reason but not really significant"?
once upon a time, it might have been important;
And it still is important.
but it is overwhelmed into insignificance by the exposure of other-
window-closing as an opportunity that would nowadays be misused by the
ill-mannered - which, as you should have observed, will be the vast
majority of commercial sites.
It is not just commercial sites. And, most of the questions I have
looked at in the recent past in the archives had nothing to do with
commercial sites. The question typically gets asked because someone
wants to remove toolbars from the window so they open a new window but
they want the main window closed so they ask how to close it. If you can
find a thread in the recent past - say 3 years - where any other
scenario has been described then you may have a point. Until then, you
are just rambling on in order to disagree with me - an American - that
you despise so much. Get over it John and move on, you will sleep better
at night.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Feb 9 '07 #8

This discussion thread is closed

Replies have been disabled for this discussion.