Location hash 属性

定义和用法
hash 属性是一个可读可写的字符串,该字符串是 URL 的锚部分(从 # 号开始的部分)。
语法
location.hash
浏览器支持
所有主要浏览器都支持 hash 属性
实例
实例
返回一个URL的主要部分。假设当前的URL是http://www.w3cschool.cc/test.htm#PART2:
<script>
document.write(location.hash);
</script>
document.write(location.hash);
</script>
以上实例输出结果:
#part2

点我分享笔记