Name

host — NN 2 IE 3 DOM 1

Synopsis

Read/Write

The combination of the hostname and port (if any) of the server that serves up the current document. If the port is explicitly part of the URL, the hostname and port are separated by a colon, just as they are in the URL.

Example

if (location.host = "www.megacorp.com:80") {
    ...
}

Value

String of hostname, optionally followed by a colon and port number.

Default

Depends on server.

Get Dynamic HTML: The Definitive Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.