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

Closing window not opened by the script - Netscape 7.1

P: n/a

Dear Folks,

The application I am working on uses Frames (TopFrame, SideFrame(Left)
and the MainFrame). On the occurance of a certain event, I am closing
the window from one of the frames. This is the script I use.

function CloseWin ()
{
window.opener = window;
window.close();
}

Works perfectly well with IE. But not with Netscape. The Javascript
console says 'Script may not close windows that were not opened by the
script'. Is there any workaround to this?

Would indeed appreciate your help on this.

Arun
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Arun Seetharam wrote:
The application I am working on uses Frames (TopFrame,
SideFrame(Left) and the MainFrame). On the occurance of
a certain event, I am closing the window from one of
the frames. This is the script I use.

function CloseWin ()
{ <snip> window.close();
}

Works perfectly well with IE.
It exploits what is generally considered a bug in IE.
But not with Netscape. The Javascript console says
'Script may not close windows that were not opened by
the script'. Is there any workaround to this?

<snip>

No. 'Script may not close windows that were not opened by the script'

Users wanting to close their browser have numerous options available to
them and do not need another.

Richard.
Jul 23 '05 #2

P: n/a
Arun Seetharam wrote:
Dear Folks,

The application I am working on uses Frames (TopFrame, SideFrame(Left)
and the MainFrame). On the occurance of a certain event, I am closing
the window from one of the frames. This is the script I use.

function CloseWin ()
{
window.opener = window;
window.close();
}

Works perfectly well with IE. But not with Netscape. The Javascript
console says 'Script may not close windows that were not opened by the
script'. Is there any workaround to this?


No, there is no workaround. And if the Microsoft folks were doing their
job, the code you posted wouldn't work in IE either (and may hopefully
stop working at some point in the future).

--
Grant Wagner <gw*****@agricoreunited.com>
comp.lang.javascript FAQ - http://jibbering.com/faq
Jul 23 '05 #3

P: n/a
Grant Wagner wrote:
Arun Seetharam wrote:


<--snip-->
Works perfectly well with IE. But not with Netscape. The Javascript
console says 'Script may not close windows that were not opened by the
script'. Is there any workaround to this?

No, there is no workaround. And if the Microsoft folks were doing their
job,


And the people at OmniWeb, Opera and all the other non-Mozilla based
browsers where it works were doing their job.............

Jul 23 '05 #4

P: n/a
Oh Enlightened ones, my sincere thanks to you all of you. You have
quelled my ignorance.

Be Blessed
Arun

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #5

P: n/a


Oh Enlightened ones, my sincere thanks to you all of you. You have
quelled my ignorance.

Be Blessed
Arun

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #6

P: n/a
Randy Webb wrote:
Grant Wagner wrote:
Arun Seetharam wrote:


<--snip-->
Works perfectly well with IE. But not with Netscape. The Javascript
console says 'Script may not close windows that were not opened by the
script'. Is there any workaround to this?

No, there is no workaround. And if the Microsoft folks were doing their
job,


And the people at OmniWeb, Opera and all the other non-Mozilla based
browsers where it works were doing their job.............


I'm not sure what your point is. If it's that the authors of the browsers
mentioned above have a bug in their software by allowing this behaviour, I
agree.

Presumably you are mentioning the other browsers to demonstrate that it is a
"feature" and not a "bug". However, if it were a "feature", then:

window.close();

would just *work* without a prompt. You would not have to resort to:

window.opener = window; window.close();

to get it to do what you want. The fact that you have to "fool" the browser
into having a valid value assigned to the "window.opener" property
demonstrates that it is a bug.

After all, what is the point of including code that stops you from executing
window.close(); if there is a way to avoid the warning? Why not introduce a
proprietary feature like window.close(true); to suppress the warning? Such
functionality would break no existing code and allow Microsoft to make it's
"feature" available in a way that doesn't involve what is obviously a hack.

When I reported the problem to Microsoft as a security vulnerability, I
received a very polite reply that basically Microsoft acknowledges that it is
a bug, but does not regard it as a "security" problem, because the user can
simply re-open the closed window. I guess they can't be bothered spending
some of that $60 billion cash surplus on fixing this.

Anyway, I look forward to the day some security patch or other breaks the
above code, and we are flooded with "... this used to work, what can I do
now?" type posts. I won't even try to avoid saying "I told you so", I'll just
laugh. Of course, most of these people shouldn't be trying to open new
windows in the first place given the current state of new window hatred, but
that's an argument for another time.

--
Grant Wagner <gw*****@agricoreunited.com>
comp.lang.javascript FAQ - http://jibbering.com/faq

Jul 23 '05 #7

P: n/a
Grant Wagner wrote:
Randy Webb wrote:

Grant Wagner wrote:
Arun Seetharam wrote:


<--snip-->
Works perfectly well with IE. But not with Netscape. The Javascript
console says 'Script may not close windows that were not opened by the
script'. Is there any workaround to this?
No, there is no workaround. And if the Microsoft folks were doing their
job,


And the people at OmniWeb, Opera and all the other non-Mozilla based
browsers where it works were doing their job.............

I'm not sure what your point is. If it's that the authors of the browsers
mentioned above have a bug in their software by allowing this behaviour, I
agree.


My only point was that its not just Internet Explorer that has the bug.
The implication of your statement (to me anyway) "And if the MS
folks....." was that it implied that it was an MS-only bug when its not.
Mozilla based browsers seem to be the only ones that get it right.

Jul 23 '05 #8

P: n/a
Randy Webb wrote:
Grant Wagner wrote:
No, there is no workaround. And if the Microsoft folks were doing their
job,

And the people at OmniWeb, Opera and all the other non-Mozilla based
browsers where it works were doing their job.............

I'm not sure what your point is. If it's that the authors of the browsers
mentioned above have a bug in their software by allowing this behaviour, I
agree.


My only point was that its not just Internet Explorer that has the bug.
The implication of your statement (to me anyway) "And if the MS
folks....." was that it implied that it was an MS-only bug when its not.
Mozilla based browsers seem to be the only ones that get it right.


Oh.

Agreed.

I threw together a quick test when I got your original post:

<a href="#" onclick="window.close();return false;">Close</a>
<form>
<input type="submit">
</form>

I loaded it into Opera 7.53, I clicked submit a few times (to create history),
then clicked "Close" and was shocked to discover the window just closed. Either
what I did didn't create any history, or it worked because the file was loaded
locally from the HD. I didn't bother to test any further, it just shocked me
that Opera would allow something like that.

--
Grant Wagner <gw*****@agricoreunited.com>
comp.lang.javascript FAQ - http://jibbering.com/faq

Jul 23 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.