WorkerLocation: toString() 方法

Baseline 已廣泛支援

此特性已相當成熟,可在許多裝置和瀏覽器版本上使用。自 ⁨2015 年 7 月⁩以來,各瀏覽器均已提供此特性。

注意:此功能僅在 Web Workers 中可用。

WorkerLocation 物件的 toString() 字串轉換器方法返回一個包含 worker 位置序列化 URL 的字串。它是 WorkerLocation.href 的同義詞。

語法

js
toString()

引數

無。

返回值

無(undefined)。

示例

js
// In a Web worker, on the page https://mdn.club.tw/en-US/docs/Web
const result = location.toString(); // Returns 'https://mdn.club.tw/en-US/docs/Web'

規範

規範
HTML
# workerlocation

瀏覽器相容性

另見