toString()
stringifier method of the
定位
interface returns a
USVString
containing the whole URL. It is a read-only version of
Location.href
.
string = object.toString();
// Let's imagine an <a id="myAnchor" href="https://developer.mozilla.org/en-US/docs/Location/toString"> element is in the document
var anchor = document.getElementById("myAnchor");
var result = anchor.toString(); // Returns: 'https://developer.mozilla.org/en-US/docs/Location/toString'
| 规范 | 状态 | 注释 |
|---|---|---|
| HTML 实时标准 | 实时标准 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
toString
|
Chrome 52 | Edge 12 | Firefox 22 |
IE
11
|
Opera ? | Safari ? | WebView Android 52 | Chrome Android 52 | Firefox Android 22 | Opera Android ? | Safari iOS ? | Samsung Internet Android 6.0 |
完整支持
兼容性未知
见实现注意事项。
定位
Location: assign()
Location: reload()
Location: replace()
Location: toString()