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

T

Toccoa

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
 
A

Andrew Poulos

Gérard Talbot said:
Toccoa wrote :

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

- I mean searching with Google(r) - I

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.



'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/author/dhtml/reference/methods/close_0.asp?frame=true


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

http://channel9.msdn.com/wiki/default.aspx/Channel9.InternetExplorerSecurity


http://www.gtalbot.org/BrowserBugsSection/MSIE6Bugs/ClosingWindowsNotOpenedByJS.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

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


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
 
R

Randy Webb

Andrew Poulos said the following on 2/6/2007 12:11 AM:
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.
 

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

Forum statistics

Threads
474,262
Messages
2,571,056
Members
48,769
Latest member
Clifft

Latest Threads

Top