HTMLAreaElement: toString() 方法

Baseline 已广泛支持

此特性已得到良好确立,可跨多种设备和浏览器版本使用。自 2017 年 3 月起,所有浏览器均支持此特性。

HTMLAreaElement.toString() 字符串化 方法返回一个包含完整 URL 的字符串。它是 HTMLAreaElement.href 的只读版本。

语法

js
toString()

参数

无。

返回值

一个包含元素完整 URL 的字符串。

示例

在 area 元素上调用 toString

js
// An <area id="myArea" href="/en-US/docs/HTMLAreaElement"> element is in the document
const area = document.getElementById("myArea");
area.toString(); // returns 'https://mdn.org.cn/en-US/docs/HTMLAreaElement'

规范

规范
HTML
# dom-hyperlink-href-dev

浏览器兼容性

另见