473,320 Members | 1,724 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

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

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
7 5776
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Scott | last post by:
I'm new to ASP, but I've been programming in VB for several years, and I'm having a few issues with this ASP enhancement I'm working on. I've found ASP to be a lot different than what I'm use to...
8
by: Renuka | last post by:
I have a confirmation page with an OK button. If this window has an opener then this browser window needs to go to another URL or else the window must close. Thus I have the following javascript...
3
by: NeverLift | last post by:
But, if it's not open, I don't want to open it . . . using window.open will open it if it doesn't exist, even if the url in that open is null (the window is then empty -- but it's open). The...
1
by: fogwolf | last post by:
First a basic outline of what I am trying to do: I want to have a page spawn a pop-up when you click "submit" on its form. On this pop-up page there will be another form. When you click "submit"...
19
by: Darren | last post by:
I have a page that opens a popup window and within the window, some databse info is submitted and the window closes. It then refreshes the original window using window.opener.location.reload(). ...
4
by: louise raisbeck | last post by:
I have this scenario (simplified) function addnewdata () { check for partial match already in db for information entered by user if (partialmatch succeeds) { open new window aspx page (using...
2
by: jackson2005 | last post by:
OK, I need to do three different things. On the ONLOAD event I would like a popup box to open. In this popup box I need two text boxes. One for the UserName and one for the BillingTo name. ...
11
by: Dave | last post by:
For some reason, the below lines only work on select machines. All machines are running IE6. IE SP's and OS's vary. When it doesn't work, default.aspx (the page that this code is in) opens and...
16
by: CreativeMind | last post by:
hi, i have a page calendar.aspx which returns selected date i.e window.returnValue=selectedDate; window.close(); it works fine with IE but not for Firefox. i tried...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.