How To Open URL In The Same Tab Or In The Same Window
Here we consider how to open URL in the same window or in the same tab.
Lets start with one example.
Suppose we have a button as shown below.
When we click on this button, it would navigate to Google.com.
We have used window.open for opening this link.
But the new link is opened in a new tab or window.
For opening the new link in the same tab or window, we can use following code.
By using above code, we can open a link in the same tab/window.
Else, we can use
window.location.href = "http://www.google.com" .
window.location.href = "http://www.google.com";
That's all, by using above methods, we can open a link in the same tab.