| Issue 162049 | window.open opens new window when it should open a tab | ||||||||||||||||||||||||
| Starred by 19 users | Reported by souders@google.com, Nov 20, 2012 | Back to list | |||||||||||||||||||||||
Sign in to add a comment
|
Chrome Version : 23.0.1271.64
OS Version: OS X 10.8.2
URLs (if applicable) :
Other browsers tested:
Add OK or FAIL after other browsers where you have tested this issue:
Safari 5:
Firefox 4.x:
IE 7/8/9:
What steps will reproduce the problem?
1. Call window.open 2 or more times. For example:
window.open("http://www.google.com/");
window.open("http://www.yahoo.com/");
Here's a test page: http://stevesouders.com/tests/window-open.php
What is the expected result?
All the URLs are open in a new tab.
What happens instead of that?
The first URL is opened in a new tab. All the remaining URLs are opened in a new window. We could debate whether all the URLs are opened in a new tab vs a new window. Most browsers have a setting to control this and the test works as expected. But it's really weird that Chrome mixes the behavior - first a tab then windows.
Please provide any additional information below. Attach a screenshot if possible.
The following variables do NOT change the behavior:
- using "_blank"
- sleeping (setTimeout) even 10 seconds between calls
- making sure the opener tab stays in the foreground
- choosing "Allow all sites to show pop-ups" under "Content settings"
UserAgentString: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11
,
Feb 11, 2013
I can confirm that the following browsers are affected: * Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.68 Safari/537.17 * Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.17 (KHTML, like Gecko) Ubuntu Chromium/24.0.1312.56 Chrome/24.0.1312.56 Safari/537.17
,
Feb 15, 2013
Can reproduce this using the JS on http://tab.bz/9m5hn (hit the blue button to trigger opening the links). Chrome Version 24.0.1312.52 Issue not present in FF 18.0.2 or IE10
,
Mar 10, 2013
,
Mar 28, 2013
I've been having a look at this as my first bug (please be gentle!).
As far as I can tell the source of the bug is to do with whether the event is considered to be caused by a "user gesture".
In particular the following code in RenderViewImpl::show in content/renderer/render_view_impl.cc looks to be the cause of the issue
.......
if (GetContentClient()->renderer()->AllowPopup())
opened_by_user_gesture_ = true;
// Force new windows to a popup if they were not opened with a user gesture.
if (!opened_by_user_gesture_) {
// We exempt background tabs for compat with older versions of Chrome.
// TODO(darin): This seems bogus. These should have a user gesture, so
// we probably don't need this check.
if (policy != WebKit::WebNavigationPolicyNewBackgroundTab)
policy = WebKit::WebNavigationPolicyNewPopup;
}
.......
This code seems wrong for a couple of reasons:
1) The call to AllowPopup will always return false as this is just a stub function in content/public/renderer/content_renderer_client.cc and popup blocking actually happens in chrome::AddWebContents in chrome/browser/ui/browser_tabstrip.cc .
2) It's unclear why we'd want to open new windows rather than new tabs in this case. If the user doesn't trust the site (i.e popups are blocked) then it won't matter either way. If the user does trust the site then why are we overriding the site in this specific case?
If it were my call then I think I'd just remove that entire chunk of code. That said I can see this isn't a clear cut technical issue so could someone from the Chromium team comment on the desired behaviour and then we can either remove the code or close the bug as invalid.
If the code is to be removed then I'd be happy to create a patch. I realise it's a trivial change but it'd be useful to learn the processes involved.
,
Mar 28, 2013
Just to expand on my second point as I realise it was a little unclear. The logic that blocks popups is based on whether popups are allowed for the current page and whether the window was opened due to a user gesture (i.e it is not based on whether the page is opened with type NewPopup). So with the proposed code removal the second (and subsequent) new tab is still blocked until you explicitly allow popups for that domain or allow them globally. I've tested this locally. Hope that is a bit clearer.
,
Mar 30, 2013
Would be great if you can provide a fix! Looking forward to it.
,
Sep 16, 2013
Any update on this? It's the #1 reason why I don't use Chrome as my primary browser every day.
,
Sep 26, 2013
We think this is causing an issue for us where by we call window.open and want it to appear in a pop-up (not in a tab) and it is appearing in a tab. All other browsers open in a window.
,
Aug 29, 2014
Will this ever be fixed? Is there at least a work around for this?
,
Aug 29, 2014
Thanks for looking in to this.
,
Sep 3, 2014
This bug forces me to use Firefox on a daily basis for reading most websites. Please fix??
,
Sep 12, 2014
Hi, have there been any update on this?
,
Nov 20, 2014
Any update?
window.open("http://google.com","_blank" always opens in a new tab for chrome 39.0.2171.65. All other browsers consistently open google in a new window.
,
Aug 27, 2015
,
Aug 27, 2015
,
Aug 27, 2015
,
Aug 27, 2015
The behavior has definitely changed since this bug was filed. We appear now to consistently suppress opening more than one window unless enabled by popup blocker settings, and consistently open as a tab by default. You can force a window to be opened as a popup by supplying a width and height value, eg.:
window.open('http://www.google.com/', '_blank', 'height=200,width=200');
That said, I'm sure there's still some differences between browsers here (eg. see debate here: http://stackoverflow.com/questions/726761/javascript-open-in-a-new-window-not-tab). The relevant specs appear to leave this up to the user agent:
https://drafts.csswg.org/cssom-view/#the-features-argument-to-the-open()-method
https://html.spec.whatwg.org/multipage/browsers.html#dom-open
I think the remaining differences are really a UI / user preference issue, not a platform/interop issue. But interested parties could make an argument to the spec editors to have the behavior defined more precisely for more consistent behavior between browsers.
|
||||||||||||||||||||||||
| ► Sign in to add a comment | |||||||||||||||||||||||||
Status: Untriaged
Labels: -OS-Mac -Area-Undefined OS-All Area-Compat Mstone-23