How to open a URL in same window and in same tab with JavaScript?

Spread the love

Sometimes, we want to open a URL in same window and in same tab with JavaScript.

In this article, we’ll look at how to open a URL in same window and in same tab with JavaScript.

How to open a URL in same window and in same tab with JavaScript?

To open a URL in same window and in same tab with JavaScript, we call window.open.

For instance, we write

window.open("https://www.youraddress.com", "_self");

to call window.open to open "https://www.youraddress.com".

we call it with "_self" to open the URL in the same window and tab.

Conclusion

To open a URL in same window and in same tab with JavaScript, we call window.open.

Leave a Reply

Your email address will not be published.