位置:hash 屬性
Location 介面的 hash 屬性是一個字串,其中包含一個 "#",後面跟著位置 URL 的片段識別符號。如果 URL 沒有片段識別符號,則此屬性包含一個空字串 ""。
有關更多資訊,請參閱 URL.hash。
值
字串。
示例
假設使用者已導航到 https://example.org#examples,以下程式碼將輸出 #examples
js
const result = location.hash;
console.log(result);
規範
| 規範 |
|---|
| HTML # dom-location-hash-dev |
瀏覽器相容性
載入中…