Location: toString()

toString()Location接口stringifier方法返回包含整个URL的USVString}。它是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 Living Standard Living Standard

浏览器兼容性

BCD tables only load in the browser