Location hash 属性

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

hash 属性是一个可读可写的字符串,该字符串是 URL 的锚部分(从 # 号开始的部分)。
location.hash
所有主要浏览器都支持 hash 属性
返回一个URL的主要部分。假设当前的URL是https://www.mifengjc.com/test.htm#PART2:
<script> document.write(location.hash); </script> #part2