Setting JavaScript window.location

pathname and many other properties of location and links reflect only part of the URL: http: //www.example.com/path/to/example.html?param1=2&param3=4#fragment ^protocol^hostname ^pathname ^search ^hash As you can see, the ?… part of the URL is not part of the pathname; it makes no sense to write a value containing ? to location.pathname, as that part of a URL … Read more

What is the difference between “window.location.href” and “window.location.hash”?

For a URL like http://[www.example.com]:80/search?q=devmo#test hash – returns the part of the URL that follows the # symbol, including the # symbol. You can listen for the hashchange event to get notified of changes to the hash in supporting browsers. Returns: #test href – returns the entire URL. Returns: http://[www.example.com]:80/search?q=devmo#test Read More

Difference between window.location.assign() and window.location.replace()

Using window.location.assign(“url”) will just cause a new document to load. Using window.location.replace(“url”) will replace the current document and replace the current History with that URL making it so you can’t go back to the previous document loaded. Reference: http://www.exforsys.com/tutorials/javascript/javascript-location-object.html