Bug 16175 - javascript:self.close();" close window javascript doesn't work when window is a tab
Summary: javascript:self.close();" close window javascript doesn't work when window is...
Status: RESOLVED WORKSFORME
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 523.x (Safari 3)
Hardware: Mac OS X 10.5
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-11-28 12:01 PST by Theodore Lee
Modified: 2009-10-14 07:30 PDT (History)
3 users (show)

See Also:


Attachments
test case (100 bytes, text/html)
2007-12-03 02:15 PST, Alexey Proskuryakov
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Theodore Lee 2007-11-28 12:01:34 PST
Using the following javascript/html code:

<form><input type="button" value="Close Window" onClick="javascript:self.close();"></center></form>

Safari will close a window, but only when that Window is not a tabbed window. When you have this code in a window that is a tab, pressing the button does nothing.
Comment 1 David Kilzer (:ddkilzer) 2007-11-28 23:23:18 PST
JavaScript can only close windows it opened, and since it can't open a tab without user interaction, it can't close tabs either.

It would be interesting to have support for an "_tab" target, though, that would open a new tab (as "_blank" opens a new window).

Comment 2 Theodore Lee 2007-11-29 06:31:02 PST
The behavior in Firefox is that this Javascript will close a page (whether it is a free standing Window or a tab) without any issues. IE7 will close the page as well (again, whether a free standing Window or tab), but offers up a confirmation dialog before it will close.

In each of these circumstances, the page/tab with the containing code is not a page that was opened by Javascript, but rather, by clicking through a link or landing on a page after submitting a form. 

I agree that it would be nice to have a "_tab" target, to bring Safari inline with other browsers behavior (and make it more compatible with today's web apps), the behavior should be changed to mirror Firefox/IE in that this javascript will close the Window, regardless of whether it is a free standing Window or a tab.
Comment 3 Alexey Proskuryakov 2007-12-03 02:15:52 PST
Created attachment 17671 [details]
test case

Same test, as an attachment.
Comment 4 Alexey Proskuryakov 2007-12-03 02:18:49 PST
I cannot reproduce this issue with Safari 3.0.4 or TOT on Tiger or Leopard. I've been opening two tabs with the test case, and clicking the Close button - it worked fine.

I suspect a conflict with a Safari extension - do you have any installed? 
Comment 5 Robert Blaut 2008-12-29 04:21:13 PST
(In reply to comment #4)
> I cannot reproduce this issue with Safari 3.0.4 or TOT on Tiger or Leopard.
> I've been opening two tabs with the test case, and clicking the Close button -
> it worked fine.
> 
> I suspect a conflict with a Safari extension - do you have any installed? 
> 

I also cannot reproduce the reported problem in WebKit r39474.
Comment 6 Thierry Vignaud 2009-10-14 07:30:15 PDT
Still valid as of webkit-1.1.15.1 as used by epiphany-2.28.0 or midori-0.1.10.

Duplicate of bug #13474 IMHO