location object
Contains information about the current URL.
Members
The location object has these types of members:
Methods
The location object has these methods.
| Method | Description |
|---|---|
| assign |
Loads a new HTML document. |
| reload |
Reloads the current document. |
| replace |
Replaces the current document by loading another document at the specified URL. |
Properties
The location object has these properties.
| Property | Access type | Description |
|---|---|---|
|
Sets or retrieves the subsection of the href property that follows the number sign (#). | ||
|
Sets or retrieves the hostname and port number of the location or URL. | ||
|
Sets or retrieves the host name part of the location or URL. | ||
|
Sets or retrieves the entire URL as a string. | ||
|
Read-only |
Returns the URL underlying the current webpage, including protocol scheme, domain, and port number (if any). | |
|
Sets or retrieves the file name or path specified by the object. | ||
|
Sets or retrieves the port number associated with a URL. | ||
|
Sets or retrieves the protocol portion of a URL. | ||
|
Sets or retrieves the substring of the href property that follows the question mark. |
Standards information
There are no standards that apply here.
Remarks
The href property contains the entire URL, while the other properties contain portions of the URL. The default property for the location object is location.href. For example, setting location='http://microsoft.com' is equivalent to setting location.href='http://microsoft.com'.
The browser immediately navigates to the specified URL when any of the properties listed are set.