Location: hostname

Locationhostname 属性是包含了域名的一段 USVString

Syntax

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

Examples

// 在文档流中声明了一个元素: <a id="myAnchor" href="https://developer.mozilla.org/en-US/docs/Location.hostname">
var anchor = document.getElementById("myAnchor");
var result = anchor.hostname; // Returns:'developer.mozilla.org'

Specifications

Specification
HTML Standard
# dom-location-hostname-dev

Browser compatibility

BCD tables only load in the browser