Skip to content

Commit

Permalink
Improve example of location.hostname (#11720)
Browse files Browse the repository at this point in the history
This should make the difference to `location.host` clearer.
  • Loading branch information
apepper authored Jan 4, 2022
1 parent a1e469e commit ab13ba1
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions files/en-us/web/api/location/hostname/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ object.hostname = string;
## Examples

```js
// 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'
var anchor = document.createElement("a");
anchor.href = "https://developer.mozilla.org:4097/en-US/docs/Location.hostname";

console.log(anchor.hostname); // developer.mozilla.org
```

## Specifications
Expand Down

0 comments on commit ab13ba1

Please sign in to comment.