Categories
JavaScript Answers

How to add target=”_blank” to JavaScript window.location with JavaScript?

Spread the love

Sometimes, we want to add target="_blank" to JavaScript window.location with JavaScript.

In this article, we’ll look at how to add target="_blank" to JavaScript window.location with JavaScript.

How to add target="_blank" to JavaScript window.location with JavaScript?

To add target="_blank" to JavaScript window.location with JavaScript, we call window.open with '_blank'.

For instance, we write

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

to call window.open with the URL we want to open and '_blank' to open the URL in a new tab or window.

Conclusion

To add target="_blank" to JavaScript window.location with JavaScript, we call window.open with '_blank'.

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 *