The location object and its href property

The location object is contained in the window object and represents the actual location field of the window. The window reference is optional: 'window.location' same as 'location'.
The href property represents the URL that is in the location field.
JavaScript allows you to change the location (or page that is currently loaded into the window) by simply setting it equal to another URL:
You can achieve the same results by appending "location" with "href":
When to use href with location
Anytime you need to find a specific part of the URL such as a folder name, or if you need to extract form data that has been appended to the URL, you should use "location.href". This is because the href property is a string, whereas location is an object. Assigning "location.href" to a variable allows us to use JavaScript's built-in string methods to manipulate and/or extract information from the URL.

View the Source

Home | Contact