Location: 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 pathname của giao diện Location là một chuỗi chứa đường dẫn của URL cho location. Nếu không có đường dẫn, pathname sẽ rỗng; ngược lại, pathname chứa một '/' ở đầu theo sau bởi đường dẫn của URL, không bao gồm query string hoặc fragment.
Giá trị
Một chuỗi.
Ví dụ
js
// Giả sử chúng ta đang ở URL https://mdn.go-mizu.dev/vi/docs/Web/API/Location/pathname#examples
console.log(location.pathname); // '/vi/docs/Web/API/Location/pathname'
Thông số kỹ thuật
| Specification |
|---|
| HTML> # dom-location-pathname-dev> |