Skip to content

Commit

Permalink
Detail domain name for hostname
Browse files Browse the repository at this point in the history
  • Loading branch information
zjffun committed Mar 9, 2024
1 parent 9244c7c commit 26d4399
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion files/en-us/web/api/location/hostname/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ browser-compat: api.Location.hostname
{{ApiRef("URL API")}}

The **`hostname`** property of the {{domxref("Location")}}
interface is a string containing the domain of the URL.
interface is a string containing the {{glossary("domain name")}} of the URL.

## Value

Expand All @@ -20,6 +20,11 @@ A string.
```js
console.log(window.location.hostname);
// developer.mozilla.org

const anchor = document.createElement("a");
anchor.href = "https://developer.mozilla.org:4097/";
console.log(anchor.hostname === "developer.mozilla.org");
// The port number is not included in hostname
```

## Specifications
Expand Down

0 comments on commit 26d4399

Please sign in to comment.