HTMLAnchorElement: thuộc tính pathname

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 HTMLAnchorElement.pathname là một chuỗi bắt đầu bằng '/' theo sau là đường dẫn của URL, không bao gồm chuỗi truy vấn hoặc phân đoạn (hoặc chuỗi rỗng nếu không có đường dẫn).

Giá trị

Một chuỗi.

Ví dụ

js
// Một phần tử <a id="myAnchor" href="/vi/docs/HTMLAnchorElement"> có trong tài liệu
const anchor = document.getElementById("myAnchor");
anchor.pathname; // trả về '/vi/docs/HTMLAnchorElement'

Đặc tả kỹ thuật

Specification
HTML
# dom-hyperlink-pathname-dev

Trình duyệt hỗ trợ

Xem thêm