X
HOME HTML5 CSS3 JAVASCRIPT SQL PHP5 JQUERY ANGULAR BOOTSTRAP3 XML MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

Location hostname Property

Location Object Reference Location Object

Example

Return the hostname of the current URL:

var x = location.hostname;

The result of x will be:


Try it yourself »


Definition and Usage

The hostname property sets or returns the hostname of a URL.


Browser Support

Property
hostname Yes Yes Yes Yes Yes


Syntax

Return the hostname property:

location.hostname

Set the hostname property:

location.hostname=hostname

Property Values

Value Type Description
hostname String Specifies the hostname of the URL

Technical Details

Return Value: A String, representing the domain name, or the IP address of a URL


Location Object Reference Location Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE

facebook