;

How to Open a URL in Same Window or in Same Tab using JavaScript


Tutorialsrack 06/03/2022 Jquery Javascript

In this article, you’ll learn how to open a URL in the same window or same tab using javascript. In HTML, we used the anchor tag to open URLs in a new tab in an elementary and straightforward manner. Sometimes, we need to do the same things using Javascript. In this case, you can use the window.open() method which proves to be helpful. 

How to Open a URL in New Tab using JavaScript

The window.open() method is used to open a self window depending on the browser setting and the parameter values. You can use _self value in the second parameter of the window.open() method to open the URL in the same tab or in the same window using JavaScript.

Here is an example to open a URL in the same tab using Javascript.

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

I hope this article will help you to understand how to open a URL in the same window or same tab using javascript.

Share your valuable feedback, please post your comment at the bottom of this article. Thank you!


Related Posts



Comments

Recent Posts
Tags