aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/location/tostring/index.html
blob: cc7beca0532bb72c47aca16e5c151e4ea9c232a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
---
title: 'Location: toString()'
slug: Web/API/Location/toString
translation_of: Web/API/Location/toString
---
<p><font><font>{{ApiRef("Location")}}</font></font></p>

<p><strong><code>toString()</code></strong><font><font>{{domxref("Location")}}接口</font><font></font><font>stringifier方法返回包含整个URL的{{domxref("USVString")}}}。</font><font>它是{{domxref("Location.href")}}的只读版本。</font></font></p>

<h2 id="句法"><font><font>句法</font></font></h2>

<pre class="syntaxbox notranslate"><em>string</em> = <em>object</em>.toString();</pre>

<h2 id="例子"><font><font>例子</font></font></h2>

<pre class="brush: js notranslate">// Let's imagine an &lt;a id="myAnchor" href="https://developer.mozilla.org/en-US/docs/Location/toString"&gt; element is in the document
var anchor = document.getElementById("myAnchor");
var result = anchor.toString(); // Returns: 'https://developer.mozilla.org/en-US/docs/Location/toString'
</pre>

<h2 id="技术指标"><font><font>技术指标</font></font></h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col"><font><font>规范</font></font></th>
   <th scope="col"><font><font>状态</font></font></th>
   <th scope="col"><font><font>评论</font></font></th>
  </tr>
  <tr>
   <td><font><font>{{SpecName("HTML WHATWG","#dom-location-href")}}</font></font></td>
   <td><font><font>{{Spec2("HTML WHATWG")}}</font></font></td>
   <td></td>
  </tr>
 </tbody>
</table>

<h2 id="浏览器兼容性"><font><font>浏览器兼容性</font></font></h2>



<p><font><font>{{Compat("api.Location.toString")}}</font></font></p>