host Property

Internet Development Index

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

Syntax

HTMLN/A
Scriptingobject.host [ = sHost ]

Possible Values

sHostString that specifies or receives the host name and port number.

The property is read/write. The property has no default value.

Expressions can be used in place of the preceding value(s), as of Microsoft® Internet Explorer 5. For more information, see About Dynamic Properties.

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.

Example

This example function returns the host property of the current page location.

function getHost()
{
return document.location.host;
}

Standards Information

There is no public standard that applies to this property.

Applies To

A, AREA, location