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
Location對象