Open a URL in a new tab (and not a new window)

Whether to open the URL in a new tab or a new window, is actually controlled by the user's browser preferences. There is no way to override it in JavaScript. The window.open() method is used to open a new browser window or a new tab depending on the browser setting and the parameter values.

Open URL in New Tab using JavaScript

How to Open a URL in a new tab If you want to open URl in a new tab, you have to use "_blank" in second parameter of window.open(). Also, do not add a third parameter to it as it will result in the opening of a new window rather than a tab.
window.open("https://net-informations.com", '_blank');
run this source code Browser View

Click the button to open a new tab

Full Source | JavaScript
<html> <body> <p>Click the button to open a new tab </p> <button onclick="newTab()">Click here to open New Tab</button> <script type="text/javascript"> function newTab() { window.open("https://net-informations.com", '_blank'); } </script> </body> </html>
You could do it this way calling a direct function, or by adding an event listener to your DOM object.

Method-2 : Open URL in New Tab

run this source code Browser View

Click the button to open a new tab

Full Source | JavaScript
<html> <body> <p>Click the button to open a new tab </p> <input type="button" value="Open New Tab" onclick="window.open('https://net-informations.com')" /> </body> </html>
You cannot expect the same behavior for window.open to be true across all of Internet Explorer, Opera, Firefox, and Chrome, because of the different ways in which they handle a user's browser preferences.