URL: 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 September 2016.

Note: This feature is available in Web Workers.

Thuộc tính pathname của giao diện URL là một chuỗi chứa phần đường dẫn của URL, bắt đầu bằng "/", không bao gồm query string hoặc fragment.

Thuộc tính này có thể được đặt để thay đổi đường dẫn của URL.

Giá trị

Một chuỗi.

Ví dụ

js
const url = new URL(
  "https://mdn.go-mizu.dev/vi/docs/Web/API/URL/pathname",
);
console.log(url.pathname); // "/vi/docs/Web/API/URL/pathname"

url.pathname = "/fr/docs/Web/API/URL/pathname";
console.log(url.pathname); // "/fr/docs/Web/API/URL/pathname"

Thông số kỹ thuật

Thông số kỹ thuật
URL
# dom-url-pathname

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

Xem thêm

  • Giao diện URL mà thuộc tính này thuộc về.