Location: hostname

The hostname property of the Location interface is a USVString containing the domain of the URL.

Syntax

string = object.hostname;
object.hostname = string;

Examples

// Let's an <a id="myAnchor" href="/en-US/docs/Location.hostname"> element be in the document
var anchor = document.getElementById("myAnchor");
var result = anchor.hostname; // Returns:'developer.mozilla.org'

Specifications

Specification Status Comment
HTML Living Standard
The definition of 'hostname' in that specification.
Living Standard Initial definition.

Browser compatibility

BCD tables only load in the browser