Categories
JavaScript Answers

How to simulate target=”_blank” in JavaScript?

Spread the love

Sometimes, we want to simulate target="_blank" in JavaScript.

In this article, we’ll look at how to simulate target="_blank" in JavaScript.

How to simulate target="_blank" in JavaScript?

To simulate target="_blank" in JavaScript, we call the window.open method.

For instance, we write

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

to call window.open to open http://www.example.com.

We call it with '_blank' to show the page in a new window.

Conclusion

To simulate target="_blank" in JavaScript, we call the window.open method.

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 *