Search w3schools.com:

SHARE THIS PAGE

Location host Property

Location Object Reference Location Object

Definition and Usage

The host property returns the hostname and port of a URL.

Syntax

location.host


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The host property is supported in all major browsers.


Example

Example

Return the hostname and port of the current URL:

<script>

document.write(location.host);

</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]