window.close() in <frameset onload> does NOT close browser

RESOLVED DUPLICATE of bug 190515

Status

()

RESOLVED DUPLICATE of bug 190515
16 years ago
15 years ago

People

(Reporter: hampton, Unassigned)

Tracking

Trunk
x86
Windows XP
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

16 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.3) Gecko/20030312
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.3) Gecko/20030312

Using a frameset document as follows:

<FRAMESET
 ...
OnLoad=StartMeUp()>
<frame
...
>
<frame
...
>
<frame
...
>
</FRAMESET>


then defining the StartMeUp function as follows:

<script language=Javascript>
function StartMeUp()
{
alert("You can't run this page with Mozilla, I'm closing this window.");
window.close();
}
</script>

fails to close the browser window as it should.  The code works in IE 5.0+ and
Navigator 7.0.

Reproducible: Always

Steps to Reproduce:
1.Just call a page with the above code.
2.
3.

Actual Results:  
The browser went on to run code which was designed for IE and had to be
terminated at the OS level.

Expected Results:  
Close the browser.

Comment 1

16 years ago
Browser, not engine. The JavaScript Engine component is for bugs
in the abstract JavaScript language. This concerns the abstract
objects Date(), String(), RegExp(), etc., and not browser objects
such as |window|, |document|, |frames|, etc.

Reassigning to DOM Level 0, although this may be a duplicate.
I will look that up -
Assignee: rogerl → dom_bugs
Component: JavaScript Engine → DOM Level 0
QA Contact: pschwartau → ashishbhatt

Comment 2

16 years ago
I think this is by design. 

See bug 32571, "window.close() can close windows it doesn't own".
That was fixed on 2002-12-04.  As a result of that fix, there is
a new user preference:

    pref("dom.allow_scripts_to_close_windows",  false);


Unless set to true, window.close() and self.close() will not work
unless the same script used window.open() to open the window.

Note: the same-origin policy of the Security component already
prevented a script from closing a window it doesn't own; this stops
a script from closing a human-opened window.

I hope I have this right; I'll let others comment - cc'ing Mitch.

Updated

16 years ago
Summary: In a javascript function called by the onload event issuing window.close() does NOT close the browser as it should. → window.close() does NOT close the browser on <body onload>

Updated

16 years ago
Summary: window.close() does NOT close the browser on <body onload> → window.close() in <frameset onload> does NOT close browser

Comment 3

15 years ago

*** This bug has been marked as a duplicate of 190515 ***
Status: UNCONFIRMED → RESOLVED
Last Resolved: 15 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.