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.

How To Open URL In The Same Tab Or In The Same Window, Open URL In The Same Tab, Open URL In The Same Window, How To Open URL In The Same Tab, How To Open URL In The Same Window, Open URL In The Same Tab Using Jquery, Open URL In The Same Window  Using Jquery,  Open URL In The Same Tab Using JavaScript, Open URL In The Same Window  Using JavaScript, Jquery, Open Tab, Open Window, JavaScript, HTML, PHP

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.

window.open("www.google.com","_self");


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.