Skip to content

Commit

Permalink
AutoCorrect files/zh-cn/web/api/url*/ (#5894)
Browse files Browse the repository at this point in the history
* AutoCorrect files/zh-cn/web/api/url*/

* Apply suggestions from code review

Co-authored-by: A1lo <yin199909@aliyun.com>
  • Loading branch information
huacnlee and yin1999 authored Jun 2, 2022
1 parent b7f00c4 commit e79d2a0
Show file tree
Hide file tree
Showing 24 changed files with 75 additions and 75 deletions.
12 changes: 6 additions & 6 deletions files/zh-cn/web/api/url/createobjecturl/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
---
<div>{{ApiRef("URL")}}</div>

<p><strong><code>URL.createObjectURL()</code></strong> 静态方法会创建一个 {{domxref("DOMString")}},其中包含一个表示参数中给出的对象的URL。这个 URL 的生命周期和创建它的窗口中的 {{domxref("document")}} 绑定。这个新的URL 对象表示指定的 {{domxref("File")}} 对象或 {{domxref("Blob")}} 对象。</p>
<p><strong><code>URL.createObjectURL()</code></strong> 静态方法会创建一个 {{domxref("DOMString")}},其中包含一个表示参数中给出的对象的 URL。这个 URL 的生命周期和创建它的窗口中的 {{domxref("document")}} 绑定。这个新的 URL 对象表示指定的 {{domxref("File")}} 对象或 {{domxref("Blob")}} 对象。</p>

<p>{{AvailableInWorkers}}</p>

Expand All @@ -33,11 +33,11 @@ <h3 id="参数">参数</h3>

<h3 id="返回值">返回值</h3>

<p>一个{{domxref("DOMString")}}包含了一个对象URL,该URL可用于指定源 <code>object</code>的内容。</p>
<p>一个{{domxref("DOMString")}}包含了一个对象 URL,该 URL 可用于指定源 <code>object</code>的内容。</p>

<h2 id="示例">示例</h2>

<p>查看<a href="/zh-CN/docs/Using_files_from_web_applications#Example.3A_Using_object_URLs_to_display_images" title="https://developer.mozilla.org/en/Using_files_from_web_applications#Example:_Using_object_URLs_to_display_images">使用对象URL显示图片</a>.</p>
<p>查看<a href="/zh-CN/docs/Using_files_from_web_applications#Example.3A_Using_object_URLs_to_display_images" title="https://developer.mozilla.org/en/Using_files_from_web_applications#Example:_Using_object_URLs_to_display_images">使用对象 URL 显示图片</a>.</p>

<h2 id="Notes" name="Notes">附注</h2>

Expand All @@ -47,9 +47,9 @@ <h3 id="内存管理">内存管理</h3>

<p>浏览器在 document 卸载的时候,会自动释放它们,但是为了获得最佳性能和内存使用状况,你应该在安全的时机主动释放掉它们。</p>

<h3 id="使用相对URLs作为媒体流">使用相对URLs作为媒体流</h3>
<h3 id="使用相对URLs作为媒体流">使用相对 URLs 作为媒体流</h3>

<p>在旧版本的媒体资源规范中,添加流作为{{HTMLElement("video")}}元素需要创建一个关于 {{domxref("MediaStream")}}的对象URL。现已没必要这样做了,浏览器已经移除了该操作的支持。</p>
<p>在旧版本的媒体资源规范中,添加流作为{{HTMLElement("video")}}元素需要创建一个关于 {{domxref("MediaStream")}}的对象 URL。现已没必要这样做了,浏览器已经移除了该操作的支持。</p>

<div class="blockIndicator warning">
<p>重要:如果你为了去添加流作为媒体元素,而仍旧使用着依赖{{domxref("URL.createObjectURL", "createObjectURL()")}} 的代码,你需要更新的代码,仅需要设定{{domxref("HTMLMediaElement.srcObject", "srcObject")}} 到`<code>MediaStream</code> `即可。</p>
Expand Down Expand Up @@ -90,7 +90,7 @@ <h2 id="浏览器兼容性">浏览器兼容性</h2>
<h2 id="See_also" name="See_also">相关链接</h2>

<ul>
<li><a href="/zh-CN/docs/Using_files_from_web_applications" title="Using files from web applications">在web应用程序中使用文件</a></li>
<li><a href="/zh-CN/docs/Using_files_from_web_applications" title="Using files from web applications">在 web 应用程序中使用文件</a></li>
<li><a href="/en-US/docs/Using_files_from_web_applications#Example_Using_object_URLs_to_display_images" title="https://developer.mozilla.org/en/Using_files_from_web_applications#Example:_Using_object_URLs_to_display_images">Using object URLs to display images</a></li>
<li>{{domxref("URL.revokeObjectURL()")}}</li>
<li>{{domxref("HTMLMediaElement.srcObject")}}</li>
Expand Down
4 changes: 2 additions & 2 deletions files/zh-cn/web/api/url/hash/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
---
<div>{{ APIRef("URL API") }}</div>

<p>{{domxref("URL")}} 接口的 <strong><code>hash</code></strong> 属性返回一个 {{domxref("USVString")}},其中会包含URL标识中的 <code>'#'</code> 和 fragment 标识符(fragment 即我们通常所说的 URL hash)。</p>
<p>{{domxref("URL")}} 接口的 <strong><code>hash</code></strong> 属性返回一个 {{domxref("USVString")}},其中会包含 URL 标识中的 <code>'#'</code> 和 fragment 标识符(fragment 即我们通常所说的 URL hash)。</p>

<p>这里 fragment 不会经过<a href="/en-US/docs/Glossary/percent-encoding">百分比编码</a>URL编码)。如果 URL 中没有 fragment,该属性会包含一个空字符串 —— <code>""</code>.</p>
<p>这里 fragment 不会经过<a href="/en-US/docs/Glossary/percent-encoding">百分比编码</a>URL 编码)。如果 URL 中没有 fragment,该属性会包含一个空字符串 —— <code>""</code>.</p>

<p>{{AvailableInWorkers}}</p>

Expand Down
30 changes: 15 additions & 15 deletions files/zh-cn/web/api/url/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
---
<div>{{APIRef("URL API")}}</div>

<p><strong><code>URL</code></strong>接口用于解析,构造,规范化和编码 {{glossary("URL", "URLs")}}。 它通过提供允许您轻松阅读和修改URL组件的属性来工作。 通常,通过在调用URL的构造函数时将URL指定为字符串或提供相对URL和基本URL来创建新的URL对象。 然后,您可以轻松读取URL的已解析组成部分或对URL进行更改</p>
<p><strong><code>URL</code></strong>接口用于解析,构造,规范化和编码 {{glossary("URL", "URLs")}}。 它通过提供允许您轻松阅读和修改 URL 组件的属性来工作。 通常,通过在调用 URL 的构造函数时将 URL 指定为字符串或提供相对 URL 和基本 URL 来创建新的 URL 对象。 然后,您可以轻松读取 URL 的已解析组成部分或对 URL 进行更改</p>

<p>如果浏览器尚不支持{{domxref("URL.URL", "URL()")}}构造函数,则可以使用{{domxref("Window")}}中的{{domxref("Window.URL")}}属性。 确保检查您的任何目标浏览器是否要求对此添加前缀。</p>

Expand All @@ -15,16 +15,16 @@ <h2 id="构造器">构造器</h2>

<dl>
<dt>{{domxref("URL.URL", "new URL()")}}</dt>
<dd>创建并返回一个<code>URL</code>对象,该URL对象引用使用绝对URL字符串,相对URL字符串和基本URL字符串指定的URL</dd>
<dd>创建并返回一个<code>URL</code>对象,该 URL 对象引用使用绝对 URL 字符串,相对 URL 字符串和基本 URL 字符串指定的 URL</dd>
</dl>

<h2 id="属性">属性</h2>

<dl>
<dt>{{domxref("URL.hash", "hash")}}</dt>
<dd>包含<code>'#'</code>的{{domxref("USVString")}},后跟URL的片段标识符</dd>
<dd>包含<code>'#'</code>的{{domxref("USVString")}},后跟 URL 的片段标识符</dd>
<dt>{{domxref("URL.host", "host")}}</dt>
<dd>一个{{domxref("USVString")}},其中包含域(即主机名),后跟(如果指定了端口)“:”和URL的端口</dd>
<dd>一个{{domxref("USVString")}},其中包含域(即主机名),后跟(如果指定了端口)“:”和 URL 的端口</dd>
<dt>{{domxref("URL.hostname", "hostname")}}</dt>
<dd>包含 URL 域名的 {{domxref("USVString")}}。</dd>
<dt>{{domxref("URL.href", "href")}}</dt>
Expand All @@ -40,7 +40,7 @@ <h2 id="属性">属性</h2>
<dt>{{domxref("URL.protocol", "protocol")}}</dt>
<dd>包含 URL 协议名的 {{domxref("USVString")}},末尾带 <code>':'。</code></dd>
<dt>{{domxref("URL.search", "search")}}</dt>
<dd>一个{{domxref("USVString")}} ,指示URL的参数字符串; 如果提供了任何参数,则此字符串包括所有参数,并以开头的“?”开头 字符。</dd>
<dd>一个{{domxref("USVString")}} ,指示 URL 的参数字符串; 如果提供了任何参数,则此字符串包括所有参数,并以开头的“?”开头 字符。</dd>
<dt>{{domxref("URL.searchParams", "searchParams")}} {{readonlyInline}}</dt>
<dd>{{domxref("URLSearchParams")}}对象,可用于访问<code>search</code>中找到的各个查询参数。</dd>
<dt>{{domxref("URL.username","username")}}</dt>
Expand All @@ -54,51 +54,51 @@ <h2 id="方法">方法</h2>

<dl>
<dt>{{domxref("URL.toString", "toString()")}}</dt>
<dd>返回包含整个URL的{{domxref("USVString")}}。 它是{{domxref("URL.href")}}的同义词,尽管它不能用于修改值。</dd>
<dd>返回包含整个 URL 的{{domxref("USVString")}}。 它是{{domxref("URL.href")}}的同义词,尽管它不能用于修改值。</dd>
<dt>{{domxref("URL.toJSON", "toJSON()")}}</dt>
<dd>返回包含整个URL的{{domxref("USVString")}}。 它返回与<code>href</code>属性相同的字符串。</dd>
<dd>返回包含整个 URL 的{{domxref("USVString")}}。 它返回与<code>href</code>属性相同的字符串。</dd>
</dl>

<h2 id="静态方法">静态方法</h2>

<dl>
<dt>{{domxref("URL.createObjectURL", "createObjectURL()")}}</dt>
<dd>返回一个{{domxref("DOMString")}} ,包含一个唯一的blob链接(该链接协议为以blob:,后跟唯一标识浏览器中的对象的掩码)。</dd>
<dd>返回一个{{domxref("DOMString")}} ,包含一个唯一的 blob 链接(该链接协议为以 blob:,后跟唯一标识浏览器中的对象的掩码)。</dd>
<dt>{{domxref("URL.revokeObjectURL", "revokeObjectURL()")}}</dt>
<dd>销毁之前使用{{ domxref("URL.createObjectURL()") }}方法创建的URL实例</dd>
<dd>销毁之前使用{{ domxref("URL.createObjectURL()") }}方法创建的 URL 实例</dd>
</dl>

<h2 id="使用说明">使用说明</h2>

<p>如果<code>url</code>参数是相对URL,则构造函数将使用<code>url</code>参数和可选的<code>base</code>参数作为基础。</p>
<p>如果<code>url</code>参数是相对 URL,则构造函数将使用<code>url</code>参数和可选的<code>base</code>参数作为基础。</p>

<pre>const url = new URL('../cats', 'http://www.example.com/dogs');
console.log(url.hostname); // "www.example.com"
console.log(url.pathname); // "/cats"
</pre>

<p>可以设置URL属性以构造URL</p>
<p>可以设置 URL 属性以构造 URL</p>

<pre>url.hash = 'tabby';
console.log(url.href); // "http://www.example.com/cats#tabby"
</pre>

<p>URL根据 {{RFC(3986)}}中的规则进行编码。 例如:</p>
<p>URL 根据 {{RFC(3986)}}中的规则进行编码。 例如:</p>

<pre>url.pathname = 'démonstration.html';
console.log(url.href); // "http://www.example.com/d%C3%A9monstration.html"
</pre>

<p>{{domxref("URLSearchParams")}}接口可用于构建和处理URL查询字符串</p>
<p>{{domxref("URLSearchParams")}}接口可用于构建和处理 URL 查询字符串</p>

<p>要从当前窗口的URL获取搜索参数,可以执行以下操作:</p>
<p>要从当前窗口的 URL 获取搜索参数,可以执行以下操作:</p>

<pre>// https://some.site/?id=123
const parsedUrl = new URL(window.location.href);
console.log(parsedUrl.searchParams.get("id")); // "123"
</pre>

<p>URL的{{domxref("URL.toString", "toString()")}}方法仅返回{{domxref("URL.href", "href")}} 属性的值,因此构造函数可以 用于直接对URL进行规范化和编码</p>
<p>URL 的{{domxref("URL.toString", "toString()")}}方法仅返回{{domxref("URL.href", "href")}} 属性的值,因此构造函数可以 用于直接对 URL 进行规范化和编码</p>

<pre>const response = await fetch(new URL('http://www.example.com/démonstration.html'));</pre>

Expand Down
8 changes: 4 additions & 4 deletions files/zh-cn/web/api/url/origin/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
---
<p>{{APIRef("URL API")}}</p>

<p><code><strong>URL</strong></code><strong><code>.origin</code></strong> 是一个只读属性,返回一个 {{domxref("USVString")}} 类型值,包含 URL 源经过 Unicode 序列化之后的值, 也就是:</p>
<p><strong><code>URL.origin</code></strong> 是一个只读属性,返回一个 {{domxref("USVString")}} 类型值,包含 URL 源经过 Unicode 序列化之后的值也就是:</p>

<ul>
<li>对于使用 <code>http</code> 或者 <code>https</code> 协议的 URL, 返回协议名, 然后是 <code>'://'</code>, 然后是域, 然后是 <code>':'</code>, 最后是端口号 (默认端口是 <code>80</code> 和 <code>443</code>);</li>
<li>对于使用 <code>file:</code> 协议的 URL, 返回值因浏览器而异;</li>
<li>对于使用 <code>blob:</code> 协议的 URL, 返回值是 <code>blob:</code> 后跟随的源地址. 例如 <code>"blob:https://mozilla.org"</code> 将会返回 <code>"https://mozilla.org".</code></li>
<li>对于使用 <code>http</code> 或者 <code>https</code> 协议的 URL, 返回协议名然后是 <code>'://'</code>, 然后是域然后是 <code>':'</code>, 最后是端口号 (默认端口是 <code>80</code> 和 <code>443</code>);</li>
<li>对于使用 <code>file:</code> 协议的 URL返回值因浏览器而异;</li>
<li>对于使用 <code>blob:</code> 协议的 URL返回值是 <code>blob:</code> 后跟随的源地址例如 <code>"blob:https://mozilla.org"</code> 将会返回 <code>"https://mozilla.org".</code></li>
</ul>

<p>{{AvailableInWorkers}}</p>
Expand Down
2 changes: 1 addition & 1 deletion files/zh-cn/web/api/url/pathname/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
---
<div>{{ApiRef("URL API")}}</div>

<p>{{domxref("URL")}}接口的<strong><code>pathname</code></strong>属性是一个{{domxref("USVString")}},包含一个初始 <code>'/'</code> 和URL的路径(如果没有路径,则为空字符串)</p>
<p>{{domxref("URL")}}接口的<strong><code>pathname</code></strong>属性是一个{{domxref("USVString")}},包含一个初始 <code>'/'</code> 和 URL 的路径 (如果没有路径,则为空字符串)</p>

<p>{{AvailableInWorkers}}</p>

Expand Down
2 changes: 1 addition & 1 deletion files/zh-cn/web/api/url/port/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
---
<div>{{ApiRef("URL API")}}</div>

<div>{{domxref("URL")}} 接口的端口属性是包含了URL的端口号信息的{{domxref("USVString")}}值,如果URL中不包含明确的端口号,这个属性将为<code>''</code>.</div>
<div>{{domxref("URL")}} 接口的端口属性是包含了 URL 的端口号信息的{{domxref("USVString")}}值,如果 URL 中不包含明确的端口号,这个属性将为<code>''</code>.</div>



Expand Down
2 changes: 1 addition & 1 deletion files/zh-cn/web/api/url/protocol/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
---
<div>{{ApiRef("URL API")}}</div>

<div>{{domxref("URL")}}接口的<strong><code>protocol</code></strong>是一个包含URL协议的{{domxref("USVString")}}值,此值包含协议后的<code>':'</code>.</div>
<div>{{domxref("URL")}}接口的<strong><code>protocol</code></strong>是一个包含 URL 协议的{{domxref("USVString")}}值此值包含协议后的<code>':'</code>.</div>

<p>{{AvailableInWorkers}}</p>

Expand Down
2 changes: 1 addition & 1 deletion files/zh-cn/web/api/url/search/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
---
<div>{{ApiRef("URL API")}}</div>

<p>{{domxref("URL")}} 接口的<strong><code>search</code></strong> 属性是一个搜索字符串, 也称为查询字符串,这是一个{{domxref("USVString")}}包含一个 <code>'?'</code>后面跟着URL的参数</p>
<p>{{domxref("URL")}} 接口的<strong><code>search</code></strong> 属性是一个搜索字符串, 也称为查询字符串,这是一个{{domxref("USVString")}}包含一个 <code>'?'</code>后面跟着 URL 的参数</p>

<p>现代浏览器提供{{domxref("URL.searchParams")}}属性,以便轻松解析查询字符串中的参数。</p>

Expand Down
6 changes: 3 additions & 3 deletions files/zh-cn/web/api/url/tojson/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
---
<p>{{APIRef("URL API")}}</p>

<p>{{domxref("URL")}}接口的 <strong>toJSON() </strong>方法返回一个{{domxref("USVString")}},其中包含一个序列化的URL版本,尽管在实践中它似乎与{{domxref("URL.toString()")}}有相同的效果。</p>
<p>{{domxref("URL")}}接口的 <strong>toJSON() </strong>方法返回一个{{domxref("USVString")}},其中包含一个序列化的 URL 版本,尽管在实践中它似乎与{{domxref("URL.toString()")}}有相同的效果。</p>

<p>{{AvailableInWorkers}}</p>

Expand All @@ -22,7 +22,7 @@ <h3 id="返回值">返回值</h3>
<h2 id="例子">例子</h2>

<pre class="notranslate">const url = new URL("https://developer.mozilla.org/en-US/docs/Web/API/URL/toString");
url.toJSON(); // 应该以字符串形式返回URL</pre>
url.toJSON(); // 应该以字符串形式返回 URL</pre>

<h2 id="说明">说明</h2>

Expand All @@ -36,7 +36,7 @@ <h2 id="说明">说明</h2>
<tr>
<td>{{SpecName('URL', '#dom-url-tojson', 'toJSON()')}}</td>
<td>{{Spec2('URL')}}</td>
<td>初步定义.</td>
<td>初步定义</td>
</tr>
</tbody>
</table>
Expand Down
2 changes: 1 addition & 1 deletion files/zh-cn/web/api/url/url/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ <h3 id="参数">参数</h3>

<dl class="syntaxbox">
<dt><code><var>url</var></code></dt>
<dd>是一个表示绝对或相对 URL 的 {{domxref("DOMString")}}。如果<code><var>url</var></code> 是相对 URL,则会将 <code><var>base</var></code> 用作基准 URL。如果 <code><var>url</var></code> 是绝对URL,则无论参数<code><var>base</var></code>是否存在,都将被忽略。</dd>
<dd>是一个表示绝对或相对 URL 的 {{domxref("DOMString")}}。如果<code><var>url</var></code> 是相对 URL,则会将 <code><var>base</var></code> 用作基准 URL。如果 <code><var>url</var></code> 是绝对 URL,则无论参数<code><var>base</var></code>是否存在,都将被忽略。</dd>
<dt><code><var>base</var></code> {{optional_inline}}</dt>
<dd>是一个表示基准 URL 的 {{domxref("DOMString")}},在 <em>url</em> 是相对 URL 时,它才会起效。如果未指定,则默认为 <code>''</code></dd>
</dl>
Expand Down
2 changes: 1 addition & 1 deletion files/zh-cn/web/api/url/username/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
---
<div>{{ApiRef("URL API")}}</div>

<p> {{domxref("URL")}}接口的username属性是{{domxref("USVString")}} ,其中包含域名前指定的<strong><code>username</code></strong> 。</p>
<p> {{domxref("URL")}}接口的 username 属性是{{domxref("USVString")}} ,其中包含域名前指定的<strong><code>username</code></strong> 。</p>

<p>{{AvailableInWorkers}}</p>

Expand Down
Loading

0 comments on commit e79d2a0

Please sign in to comment.