URL: hostname property - Web APIs | MDN

Value

A string.

Examples

js

const url = new URL(
  "https://developer.mozilla.org/en-US/docs/Web/API/URL/hostname",
);
console.log(url.hostname); // Logs: 'developer.mozilla.org'

url.hostname = "你好.com";
console.log(url.hostname); // Logs: 'xn--6qq79v.com'

Specifications

Specification
URL
# dom-url-hostname

Browser compatibility

See also

  • The URL interface it belongs to.

Help improve MDN

Learn how to contribute

This page was last modified on by MDN contributors.