HTMLAreaElement: hash 屬性
HTMLAreaElement 介面的 hash 屬性是一個字串,包含一個 "#" 字元,後跟 <area> 元素的 href 的片段識別符號。如果 URL 沒有片段識別符號,則此屬性包含一個空字串 ""。
有關更多資訊,請參閱 URL.hash。
值
字串。
示例
從 area 連結獲取 hash
給定此 HTML
html
<map name="infographic">
<area
id="mdn-circle"
shape="circle"
coords="130,136,60"
href="https://mdn.club.tw/#ExampleSection"
alt="MDN" />
</map>
<img
usemap="#infographic"
src="/media/examples/mdn-info.png"
alt="MDN infographic" />
您可以像這樣獲取 area 連結的 hash:
js
const area = document.getElementById("mdn-circle");
area.hash; // '#ExampleSection'
規範
| 規範 |
|---|
| HTML # dom-hyperlink-hash-dev |
瀏覽器相容性
載入中…
另見
- 它所屬的
HTMLAreaElement介面。