host property
Sets or retrieves the hostname and port number of the location or URL.
Syntax
| JavaScript | |
|---|
Property values
Type: String
the host name and port number.
Remarks
The host property is the concatenation of the hostname and port properties, separated by a colon (hostname:port). When the port property is null, the host property is the same as the hostname property.
The host property may be set at any time, although it is safer to set the href property to change a location. If the specified host cannot be found, an error is returned.
Examples
This example function returns the host property of the current page location.
function getHost() { return document.location.host; }
See also
Show: