Return the hostname of a link:
The result of x will be:
The hostname property sets or returns the hostname part of the href attribute value.
The hostname property is supported in all major browsers.
Return the hostname property:
Set the hostname property:
Value | Description |
---|---|
hostname | Specifies the hostname of a URL |
Return Value: | A String, representing the domain name (or IP address) of the URL |
---|
Change the hostname of a link:
Another example of how to change the hostname of a link:
JavaScript reference: location.hostname Property