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.club.tw/en-US/docs/HTMLAreaElement'

規範

規範
HTML
# dom-hyperlink-href-dev

瀏覽器相容性

另見