Closing window not opened by the script - Netscape 7.1

A

Arun Seetharam

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
 
R

Richard Cornford

Arun said:
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.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.
 
G

Grant Wagner

Arun said:
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).
 
R

Randy Webb

Grant said:
Arun Seetharam 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.............
 
A

Arun Seetharam

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

Be Blessed
Arun
 
A

Arun Seetharam

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

Be Blessed
Arun
 
G

Grant Wagner

Randy said:
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.
 
R

Randy Webb

Grant said:
Randy Webb wrote:




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.
 
G

Grant Wagner

Randy said:
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.
 

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,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top