HTMLAnchorElement: phương thức toString()

Baseline Widely available

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

Phương thức stringifier HTMLAnchorElement.toString() trả về một chuỗi chứa toàn bộ URL. Đây là phiên bản chỉ đọc của HTMLAnchorElement.href.

Cú pháp

js
toString()

Tham số

Không có.

Giá trị trả về

Một chuỗi chứa URL đầy đủ của phần tử.

Ví dụ

Gọi toString trên một phần tử neo

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.toString(); // trả về 'https://mdn.go-mizu.dev/vi/docs/HTMLAnchorElement'

Đặc tả kỹ thuật

Specification
HTML
# dom-hyperlink-href-dev

Trình duyệt hỗ trợ

Xem thêm