host
Summary
Sets or retrieves the hostname and port number of the location or URL.
Property of dom/Locationdom/Location
Syntax
var host = location.host;
location.host = value;
Return Value
Returns an object of type StringString
The host component of the URL.
Examples
This example function returns the host property of the current page location.
function getHost() {
return document.location.host;
}
Notes
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.
Attributions
Microsoft Developer Network: [Windows Internet Explorer API reference Article]