How to open a new tab in chrome using javascript ?

3,295 views
Skip to first unread message

rnimma...@gmail.com

unread,
Nov 13, 2014, 5:19:59 PM11/13/14
to google-chrome-...@googlegroups.com
 window.open(<url>, '_blank') opens a new window
 window.open(<url>) replaces current page URL

PhistucK

unread,
Nov 16, 2014, 9:15:16 AM11/16/14
to Google Chrome Developer Tools
No... As far as I know, window.open never replaces the current URL if you do not supply a target name. If you do supply a target and the current window name is the same as the target, it may replace the current document. _blank actually opens a new tab in Chrome.

Using the Developer Tools to evaluate such statements is a bit problematic and does not reflect the world as you may expect.
window.open requires a user gesture (a mouse click, for example) to work, or else the new window is blocked by the popup blocker.
Evaluating using the Developer Tools does not add a user gesture and therefore the window or tab or whatever is not opened.

Also, you cannot really control whether the browser opens a tab or a window as a result of window.open. You can make it open a popup window if you supply some property string as the third argument, but not control whether a full window or a tab will be opened.


PhistucK

On Fri, Nov 14, 2014 at 12:19 AM, <rnimma...@gmail.com> wrote:
 window.open(<url>, '_blank') opens a new window
 window.open(<url>) replaces current page URL

--
You received this message because you are subscribed to the Google Groups "Google Chrome Developer Tools" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-chrome-develo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-chrome-developer-tools/308f9847-0ab2-4511-9ae7-b012ede8c546%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages