• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
Actual Wizard

Actual Wizard

Great Content From Actual Wizards

  • Blogging
  • Programming
  • Social Media
  • Marketing
You are here: Home / Programming / JavaScript

How to Open a New Tab with JavaScript

November 17, 2020 by Kevin Marszalek

Opening a new browser window in a new tab can be done easily in JavaScript.

Modern web browsers provide a simple API that creates an interface called the window object.

Since the goal is to open a new location in the current browser window, we need to utilize the window interface’s open() method.

The window.open() method takes three parameters: the first being the URL, the second being the window name, and the third being the window features.

If we pass the value of ‘_blank’ as the window name (second parameter), the browser will know to open the URL in a new tab.

Note: It may seem like the 3rd parameter would be where we would want to specify ‘_blank’ as it seems like it would be considered to be a “window feature,” but that parameter actually exists to pass “name=value” pairs to the new window. This utilization of the window.open() method is very rare is unlikely to be needed outside of websites that use frames.

Open a New Tab with JavaScript Example

This is a straightforward example that will open the URL specified as the first parameter in a new tab.

window.open('https://actualwizard.com', '_blank');

The first example was a little bit generic, so here’s an example of pressing a button to open the URL in a new tab.

<script>
function open_url () {
	window.open('https://actualwizard.com', '_blank');
}
</script>
<button onclick="open_url()">Open URL in a New Tab</button>

Code Demo:

Filed Under: JavaScript

Read More From Actual Wizard

  • Understanding the Different Parts of an Email Address
    An email address has four parts; the recipient name, the @ symbol, the domain name, and the top-level domain. …
  • How to Get the Last Element of an Array in JavaScript
    There are a number of different ways to get the last element of an array in JavaScript. Below we will explore …
  • How to use document.write() in JavaScript
    How to use document.write() in JavaScript The document.write() function is commonly used when testing simple …
  • The Difference Between a Franchisor and a Franchisee Explained
    The franchised business system has two sides that play different roles in the business. The franchisor …

Primary Sidebar

More posts from this section

  • How to Get the Last Element of an Array in JavaScript
  • How to use document.write() in JavaScript
  • How to Open a New Tab with JavaScript
  • How to Convert an HTML Node to a String in JavaScript
  • JavaScript String Anchor Method Explained
  • JavaScript String Big Method Explained
  • JavaScript String Blink Method Explained
  • JavaScript String Bold Method Explained
  • JavaScript String charAt Method Explained
  • JavaScript String charCodeAt Method Explained

Copyright © 2025 ActualWizard.com

  • About
  • Terms of Service
  • Privacy Policy
  • Cookie Policy