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
URLinterface it belongs to.