1

I have used to work with attribute:

target='_blank' <!-- in HTML -->

But with JavaScript i have tried:

windows.open('my_url' [, args]);

I want to open my_url in another TAB but the problem with this function is it opens the url in a new window

I have tried also to add argument to the function like '_blank' or '_newtab' but not working. Is there any solution to open url in new tab and not in a new window ?

Drwhite
  • 1,545
  • 4
  • 21
  • 44
  • You can't specify where exactly the window should be opened to. That's up to the browser. That said, I know for a fact that IE has a "When a popup is encountered" setting with "always open in a new tab" as an option. – Niet the Dark Absol Aug 27 '13 at 13:45
  • If you have element which opens a link in new tab then simulate a click event on that element on any event. – Muhammad Talha Akbar Aug 27 '13 at 13:48

1 Answers1

0

You can not choose to open in a new tab instead of a new window but you try this trick

function OpenInNewTab(url )
{
  var win=window.open(url, '_blank');
  win.focus();
}

<div onclick="OpenInNewTab();">Something To Click On</div>

reference: Open a URL in a new tab (and not a new window) using JavaScript

Community
  • 1
  • 1
Hardy
  • 1,499
  • 2
  • 26
  • 39