Movatterモバイル変換


[0]ホーム

URL:


  1. 開発者向けのウェブ技術
  2. Web API
  3. HTMLAreaElement
  4. hostname

このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docsコミュニティーについてもっと知り、仲間になるにはこちらから。

View in EnglishAlways switch to English

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月.

hostnameHTMLAreaElement インターフェイスのプロパティで、この<area> 要素の URL のドメイン名またはIP アドレスのどちらかを含む文字列です。この URL にホスト名がない場合、このプロパティには空文字列 ("") が入ります。 IPv4 および IPv6 アドレスは、先頭の 0 が削除されるなど正規化され、ドメイン名はIDN に変換されます。

詳しくはURL.hostname を参照してください。

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

ブラウザーの互換性

関連情報

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2026 Movatter.jp