JavaScript » Location » host

Syntax:
location.host

The host property is a string comprising of the hostname and port strings.

host is a property of both the Link and the Location objects and is a string comprising of the hostname and port strings. If the port property is the default of 80, then the hostname property is the same as the host property. Assuming your current window to be the URL...
 
http://home.newco.com/products/enquiries.htm#local?email=name@otherco.com
 
...you could find out the host property as follows:

NOTE:
 
Although the host property can be set at any time, it is safer to set the href property to change a location.

Examples

Code:
document.write(location.host)
Output:
home.newco.com:80
Explanation:

...you could find out the host property as follows: