Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

host property

Sets or retrieves the hostname and port number of the location or URL.

Syntax

JavaScript

p = object.host

 

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

a
area
location

 

 

Show:
© 2016 Microsoft