Follow
Follow

How to Open URL in New Tab using JavaScript

how to open url in new tab using javascript

Open URL in New Tab Using HTML

  • HTML target attribute provides an easy and simple way to open the linked URL within the new browser window or tab.
  • You would like to use the _blank value in target attribute to open the linked URL in a new tab or window.

Example:

<a href="https://www.gphow.com/" target="_blank">Visit GpHow</a>

Open URL in New Tab Using JavaScript

  • If you would like to open URL with JavaScript, the open () method of Window interface is that the best choice.
  • The JavaScript window.open() method opens a new browser window.
  • Use _blank in the second parameter of window.open() method to open a URL during a new tab using JavaScript.

Example:

The following JavaScript code will open https://www.gphow.com/ during a new browser tab or window.

window.open('https://www.gphow.com/', '_blank');
Newsletter
Join Design Community
Get the latest updates, creative tips, and exclusive resources straight to your inbox. Let’s explore the future of design and innovation together.