Closed Bug 202955 Opened 21 years ago Closed 21 years ago

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

Categories

(Core :: DOM: Core & HTML, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 190515

People

(Reporter: hampton, Unassigned)

Details

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.
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
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.
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>
Summary: window.close() does NOT close the browser on <body onload> → window.close() in <frameset onload> does NOT close browser

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