Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

13
  • 152
    Does not work. Got a message at the right of the address bar: Popup blocked. Then I allowed popups. And voilà, it opens in a popup, not a tab! Chrome 22.0.1229.94 on OS X Lion. Commented Oct 21, 2012 at 10:28
  • 53
    @b1naryatr0phy That's because you didn't actually test it properly. Change the settings in your browsers. Whether it's opened in a tab or window is determined by your browser's settings. There's nothing you can do by calling window.open (or any Javascript) to choose how to open the new window/tab. Commented Apr 18, 2013 at 13:56
  • Question : I set url without protocol ( for example my.site.com/Controller/Index). As result i get new window (tab) by url such as url of current page (from where i use function OpenInNewTab) plus passed into function url. With protocol window opens by correct link. Why? Commented May 15, 2014 at 9:07
  • 4
    var win = window.open(url, '_blank'); the '_blank' isn't necessary, for window.open(), the second parameter is strWindowName, for: A string name for the new window. The name can be used as the target of links and forms using the target attribute of an <a> or <form> element. The name should not contain any whitespace characters. Note that strWindowName does not specify the title of the new window. Commented Nov 18, 2015 at 9:33
  • 7
    @hydRAnger same window.open() link on MDN: To open a new window on every call of window.open(), use the special value _blank for windowName. Commented Jun 7, 2020 at 8:32