Location hostname Property
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





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