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
HTML Standard (HTML)
# dom-location-hostname-dev

Browser compatibility

BCD tables only load in the browser