Attributes | description |
hash | Sets or returns from a URL beginning with # (Anchor) |
host | Sets or returns the host name and port number of the current url |
hostname | Sets or returns the current URL's hostname |
href | Sets or returns the full URL |
pathname | Set or return current path portion of the URL |
port | Set the port number to return the current URL |
portocol | Sets or returns the URL of the current protocol |
search | Sets or returns from a question mark (?) URL beginning (query part). |
method | description |
assign() | Loading new documents |
reload() | Reload the current document ( refresh the current page ) |
replace() | Replaces the current document with a new document |
Location Object Description
Location object stored in the Location property of the Window object representing the Web address of the document window that is currently displayed. It's href attribute is stored in the full URL of the document, the other attributes describe the various parts of the URL. These properties and Anchor objects (or Area object) is very similar to the URL property. When a Location object is converted to a string, href attribute value is returned. This means you can use the expression location instead location.href.
But Anchor object represents a hyperlink in the document, Location object represents the URL of the document is currently displayed in the browser (or position). But the Location object can do far more than that, it can control the position of the document displayed by the browser. If a string containing the URL of the Location object or gives its href attribute, the browser will be the new URL within the meaning of the document is loaded in, and displayed.
In addition to setting the location or location.href replace the current URL with the complete URL, you can also modify some URL, just give the other attributes assigned to the Location object. To do so would create a new URL, a different part of the original URL, the browser will load it and display it. For example, suppose that set Location object hash attribute , the browser will be transferred to a specified location in the current document. Similarly, if you set the search property , then the browser will reload additional new URL query string.
In addition to the URL property, Location object reload () method can reload the current document, the replace () can load a new document without having to create a new history for it, that is to say, in the history list browser, new the document replaces the current document.