Sets the location of the current window itself. Replaces the location of the current window with the new one.
location.href is shorthand for (you call location from global object - window, so this is ), and this is only a string with the full URL of the current website.
window.location is an object that holds all the information about the current document location (host, href, port, protocol etc.).
exampleĭifference between window.location and location.href You can use window.location object to load another page in JavaScript. If you want a cross-browser compliant JavaScript redirect script, better to use the following scripts. You can redirect a web page via JavaScript using a number of methods.