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'.
alert(location)
The href property represents the URL that is in the location field.
alert(location.href)
JavaScript allows you to change the location (or page that is currently loaded into the window) by simply setting it equal to another URL:
location='http://yahoo.com'
You can achieve the same results by appending "location" with "href":
location.href='http://yahoo.com'
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. By assigning "location.href" to a variable allows us to use various built-in string methods to manipulate and/or extract information from the URL.

View the Source