Location hash 属性

hash 属性是一个可读可写的字符串,该字符串是 URL 的锚部分(从 # 号开始的部分)。

实例

返回一个 URL 的主要部分。假设当前的 URL 是 http://www.runoob.com/test.htm#PART2

document.write(location.hash);

以上实例输出结果: #part2

猜你喜欢

转载自blog.csdn.net/HuangsTing/article/details/89094778