URL.toString()

URL.toString() 字符串化方法返回一个包含完整 URL 的 USVString。它的作用等同于只读的 URL.href

Note: 此特性在 Web Worker 中可用。

语法

string = url.toString();

参数

无。

返回值

一个USVString

参考

const url = new URL("https://developer.mozilla.org/en-US/docs/Web/API/URL/toString");
url.toString() // 应当返回字符串形式的 URL

规范

规范 状态 备注
URL
stringifier
Living Standard Initial definition.

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
toStringChrome Full support 19Edge Full support 17Firefox Full support 54IE No support NoOpera Full support YesSafari Full support YesWebView Android Full support ≤37Chrome Android Full support 25Firefox Android Full support 54Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes

Legend

Full support  
Full support
No support  
No support

参见

  • 父级接口 URL