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.org.cn/#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接口。