Search w3schools.com:

SHARE THIS PAGE

Location hostname Property

Location Object Reference Location Object

Definition and Usage

The host property returns the hostname of a URL.

Syntax

location.hostname


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The hostname property is supported in all major browsers.


Example

Example

Return the hostname of the current URL:

<script>

document.write(location.hostname);

</script>

The output of the code above will be:


Try it yourself »


Location Object Reference Location Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]