Location hash 属性
最后更新于:2022-03-26 22:11:49
Location hash 属性
Location 对象
定义和用法
hash 属性是一个可读可写的字符串,该字符串是 URL 的锚部分(从 # 号开始的部分)。
语法
浏览器支持





所有主要浏览器都支持 hash 属性
实例
实例
返回一个 URL 的主要部分。假设当前的 URL 是 http://docs.gechiui.com/w3school/test.htm#PART2:
document.write(location.hash);
以上实例输出结果:
#part2
Location 对象