Sometimes, we want to open URL in same window and in same tab with JavaScript.
In this article, we’ll look at how to open URL in same window and in same tab with JavaScript.
How to open URL in same window and in same tab with JavaScript?
To open URL in same window and in same tab with JavaScript, we call window.open
with '_self'
.
For instance, we write
window.open("https://www.example.com", "_self");
to call window.open
to open https://www.example.com in the same window or tab with '_self'
.
Conclusion
To open URL in same window and in same tab with JavaScript, we call window.open
with '_self'
.