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

window.open("https://net-informations.com", '_blank');

Click the button to open a new tab
<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

Click the button to open a new tab
<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.
Related Topics
- JavaScript Popup Boxes
- Opening a new window in JavaScript
- How to Create Drop-Down Lists in JavaScript
- How do I include a JavaScript file in another JavaScript file?
- Print the content of a Div using JavaScript/jQuery
- How to get the current URL using JavaScript ?
- How to Detect a Mobile Device with JavaScript/jQuery
- How to validate an email address in JavaScript
- JavaScript Array Iteration
- How to Remove a Specific Item from an Array in JavaScript
- What is JavaScript closures?
- How To Remove a Property from a JavaScript Object
- How to get selected value from Dropdown list in JavaScript
- How do I get the current date in JavaScript?
- How to delay/wait/Sleep in code execution | JavaScript
- How to round to at most 2 decimal places | JavaScript
- How to convert string to boolean | JavaScript
- How to check undefined in JavaScript?
- How To Copy to Clipboard | JavaScript
- How to encode a URL using JavaScript?
- How to force Input field to enter numbers only | JavaScript
- How to create multiline string in JavaScript
- How to Check for an Empty String in JavaScript?