HTMLHyperlinkElementUtils.hash 特性返回 USVString 包含 '#' followed by the fragment identifier of the URL.

The fragment is not percent-decoded . If the URL does not have a fragment identifier, this property contains an empty string, "" .

句法

string = object.hash;
object.hash = string;
					

范例

<a id="myAnchor" href="https://developer.mozilla.org/en-US/docs/HTMLHyperlinkElementUtils.href#Examples">Examples</a>
<script>
  var anchor = document.getElementById("myAnchor");
  console.log(anchor.hash); // Returns '#Examples'
</script>
					

规范

规范 状态 注释
HTML 实时标准
The definition of 'HTMLHyperlinkElementUtils.hash' in that specification.
实时标准 初始定义

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
hash Chrome Yes
Yes
Starting in Chrome 52, this property was moved to URL
Edge 12 Firefox 22
22
From Firefox 22 to Firefox 44, this property was on the URLUtils mixin. It has been moved either on the HTMLHyperlinkElementUtils mixin, or directly on the interface. Also, from Firefox 29 to Firefox 40, the returned value was incorrectly percent-decoded.
IE 5 Opera Yes
Yes
Starting in Opera 39, this property was moved to URL
Safari Yes WebView Android Yes
Yes
Starting in Chrome 52, this property was moved to URL
Chrome Android Yes
Yes
Starting in Chrome 52, this property was moved to URL
Firefox Android 22
22
From Firefox 22 to Firefox 44, this property was on the URLUtils mixin. It has been moved either on the HTMLHyperlinkElementUtils mixin, or directly on the interface. Also, from Firefox 29 to Firefox 40, the returned value was incorrectly percent-decoded.
Opera Android Yes
Yes
Starting in Opera 39, this property was moved to URL
Safari iOS Yes Samsung Internet Android Yes
Yes
Starting in Samsung Internet 6.0, this property was moved to URL

图例

完整支持

完整支持

见实现注意事项。

另请参阅

元数据

  • 最后修改:
  1. HTMLHyperlinkElementUtils
  2. 特性
    1. hash
    2. host
    3. hostname
    4. href
    5. origin
    6. password
    7. pathname
    8. port
    9. 协议
    10. search
    11. username
  3. 方法
    1. toString()
  4. 实现通过:
    1. HTMLAnchorElement
    2. HTMLAreaElement

版权所有  © 2014-2026 乐数软件    

工业和信息化部: 粤ICP备14079481号-1