Location: thuộc tính hash

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

Thuộc tính hash của giao diện Location là một chuỗi chứa "#" theo sau là fragment identifier của URL vị trí. Nếu URL không có fragment identifier, thuộc tính này chứa chuỗi rỗng "".

Xem URL.hash để biết thêm thông tin.

Giá trị

Một chuỗi.

Ví dụ

Giả sử người dùng đã điều hướng tới https://example.org#examples, đoạn mã sau sẽ ghi ra #examples:

js
const result = location.hash;
console.log(result);

Thông số kỹ thuật

Thông số kỹ thuật
HTML
# dom-location-hash-dev

Tương thích trình duyệt