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

Color Picker

colorpicker