Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Location hostname Property

Location hostname Property

Location Object Reference Location object


Definition and Usage

The hostname property is a readable and writable string that sets or returns the hostname of the current URL.

Syntax

location.hostname


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the hostname property.


Example

Example

Return the hostname of the current URL:

The example above produces the following output:

Try it »


Location Object Reference Location object