このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docsコミュニティーについてもっと知り、仲間になるにはこちらから。
HTMLAreaElement: hostname プロパティ
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015年7月.
hostname はHTMLAreaElement インターフェイスのプロパティで、この<area> 要素の URL のドメイン名またはIP アドレスのどちらかを含む文字列です。この URL にホスト名がない場合、このプロパティには空文字列 ("") が入ります。 IPv4 および IPv6 アドレスは、先頭の 0 が削除されるなど正規化され、ドメイン名はIDN に変換されます。
詳しくはURL.hostname を参照してください。
In this article
値
area 要素に関連付けられた URL のドメインを含む文字列です。セッターとゲッターの両方として使用することができます。
例
html
<textarea rows="4" cols="100"></textarea><map name="infographic"> <area shape="rect" coords="184,6,253,27" href="/ja/docs/HTMLAreaElement" alt="Mozilla" /> <area shape="circle" coords="130,136,60" href="https://coolexample.com/" alt="MDN" /></map>js
// 要素が文書内にあったとしますconst area1 = document.getElementById("area1");const area2 = document.getElementById("area2");const log = document.getElementById("log");log.textContent = `area1 hostname: ${area1.hostname} \n`; // 'developer.mozilla.org'log.textContent += `area2 hostname: ${area2.hostname}`; // 'coolexample.com'仕様書
| Specification |
|---|
| HTML> # dom-hyperlink-hostname-dev> |
ブラウザーの互換性
関連情報
- 所属先の
HTMLAreaElementインターフェイス