From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/zh-cn/web/api/location/tostring/index.html | 42 ++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 files/zh-cn/web/api/location/tostring/index.html (limited to 'files/zh-cn/web/api/location/tostring/index.html') diff --git a/files/zh-cn/web/api/location/tostring/index.html b/files/zh-cn/web/api/location/tostring/index.html new file mode 100644 index 0000000000..84a5fdddff --- /dev/null +++ b/files/zh-cn/web/api/location/tostring/index.html @@ -0,0 +1,42 @@ +--- +title: 'Location: toString()' +slug: Web/API/Location/toString +translation_of: Web/API/Location/toString +--- +

{{ApiRef(“ Location”)}}

+ +

toString(){{domxref(“ Location”)}}接口stringifier方法返回包含整个URL的{{domxref(“ USVString”)}}}。它是{{domxref(“ 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'
+
+ +

技术指标

+ + + + + + + + + + + + + + +
规范状态评论
{{SpecName('HTML WHATWG',“#dom-location-href”)}}{{Spec2('HTML WHATWG')}}
+ +

浏览器兼容性

+ + + +

{{Compat(“ api.Location.toString”)}}

-- cgit v1.2.3-54-g00ecf