Location host Property
Return the hostname and port of the current URL:
The result of x will be:
Try it yourself »
Definition and Usage
The host property sets or returns the hostname and port of a URL.
Note: If the port number is 80 (which is the default port number), the port will not be returned.
The host property is supported in all major browsers.
Return the host property:
Set the host property:
|hostname:port||String||Specifies the hostname and port of the URL|
|String||The domain name and port number, or the IP address of a URL|
Thank You For Helping Us!
Your message has been sent to W3Schools.