Categories
JavaScript Answers

How to Add target=“_blank” to window.location in JavaScript?

Spread the love

Use window.open

The window.open method lets us open a new window or tab from a given tab.

For instance, we can write:

window.open('http://example.com', '_blank');

to open a new tab that opens http://example.com.

_blank means we open a new window.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *