blob: 84a5fdddff474b7f0c408995db7396b808d0b28b (
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 <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'
</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>
<div class="hidden"><font><font>此页面上的兼容性表是根据结构化数据生成的。</font><font>如果您想贡献数据,请查看</font></font><a href="https://github.com/mdn/browser-compat-data"><font><font>https://github.com/mdn/browser-compat-data</font></font></a><font><font>并向我们发送请求请求。</font></font></div>
<p><font><font>{{Compat(“ api.Location.toString”)}}</font></font></p>
|