Closed Bug 304112 Opened 19 years ago Closed 19 years ago

javascript is not working

Categories

(Firefox :: General, defect)

x86
Windows XP
defect
Not set
major

Tracking

()

VERIFIED INVALID

People

(Reporter: vishalbansod, Unassigned)

Details

User-Agent:       Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6

I'm a developer. I'w trying to put a link in a page which will close the 
window. So i used self.close(). But its not closing the window and putting a 
message "Scripts may not close windows that were not opened by script." in 
JavaScript Console. Even i used window.close() and got the same . Same thing is 
working perfectly fine in Internet Explorer.

Reproducible: Always
This is not a bug, this is a feature, as you saw from the error message in the
console. Users are annoyed when sites can close any window, so Firefox only
allows web sites to close windows they've opened with window.open().
Status: UNCONFIRMED → RESOLVED
Closed: 19 years ago
Resolution: --- → INVALID
Reply to reporter's email:
> Now tell me what shall i use to close the window using javascript?
> I'm stuck here. Please suggest me some way to do it.
> Thanx and Regards
> Vishal D Bansod

There is no way to do it, that's the whole point. If you want to close a window,
it must be a window that you explicitly opened using window.open(). Otherwise,
you can't. There's very little reasons why you'd usually need to close windows.
See bug 183697.

In the future, please reply to comments directly in the bug, and not by email.
Status: RESOLVED → VERIFIED
An attempt to close a browser window which is not opened using "javascript" 
results into a message "Scripts may not close windows that were not opened by 
script." in "JavaScript Console". As the message contains the word "may", it's 
a little bit confusing. Does it mean that there is some special situation when 
that window can be closed through "javascript" even if it's not opened 
using "javascript"?

The application I'm developing needs a browser window to be closed. Please tell 
me any other way to implement this.

Even if you check an ICICI bank site (www.icicibank.com) uses it. When ever 
user logs out the window is closed automatically due to some security reason as 
there is a chance that user forgets to close it. But user using Mozilla, 
Firefox has to do it manually.
You need to log in before you can comment on or make changes to this bug.