Categories
JavaScript Answers

How to open new page in same window with JavaScript?

Spread the love

Sometimes, we want to open new page in same window with JavaScript.

In this article, we’ll look at how to open new page in same window with JavaScript.

How to open new page in same window with JavaScript?

To open new page in same window with JavaScript, we call the window.open method.

For instance, we write

window.open("http://example.com", "_self", false);

to call window.open with the URL we want to open and '_self' to open the new page in the same window.

Conclusion

To open new page in same window with 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 *