HTML:标记语言
CSS:样式语言
JavaScript:脚本语言
Web API:编程接口
所有 Web 技术
学习 Web 开发
发现我们的工具
更好地了解 MDN
此功能已相当成熟,可在多种设备和浏览器版本上使用。自 2016 年 7 月起,所有浏览器均已支持此功能。
toString() 方法是 Location 接口的字符串化方法,它返回一个包含完整 URL 的字符串。它是 Location.href 的只读版本。
toString()
Location
Location.href
无。
一个表示对象 URL 的字符串。
// Let's imagine this code is executed on https://example.com/path?search#hash const result = window.location.toString(); // Returns: 'https://example.com/path?search#hash'
加载中…