location Reference
The location object in JavaScript both provides a way to check on which page is the one currently loaded (useful when the same JavaScript runs on multiple pages) and also can be used by JavaScript to load a new web page in place of the current one.
Properties.
The location object provides numerous properties that return parts of the information about the current page. To make it easier to see which parts are returned in which property let's assume that we are currently on http://www.example.com:80/folder/page.htm?a=b#middle and see which part of that address is contained within each property.
- location.hash - contains #middle the current anchor point within the page
- location.host - contains www.example.com:80 the domain name and the port number
- location.hostname - contains www.example.com the domain name
- location.href - contains the full address of the web page
- location.pathname - contains folder/page.htm
- location.port - contains 80
- location.protocol - contains http:
- location.search - contains a=b
Methods
- location.reload() - forces the current page to be reloaded by the browser
- location.replace(url) - loads the specified new page into the browser overwriting the last entry in the history making it impossible to return to the prior page via the browser back button.
Assigning a value to any of the properties will also cause a new page load to occur with the appropriate part of the page address replaced by the new value specified.
Where pages are loaded using frames each separate frame will have its own location object.

