diff options
Diffstat (limited to 'files/zh-cn/glossary/origin/index.html')
-rw-r--r-- | files/zh-cn/glossary/origin/index.html | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/files/zh-cn/glossary/origin/index.html b/files/zh-cn/glossary/origin/index.html new file mode 100644 index 0000000000..83090ee98f --- /dev/null +++ b/files/zh-cn/glossary/origin/index.html @@ -0,0 +1,52 @@ +--- +title: Origin +slug: Glossary/源 +translation_of: Glossary/Origin +--- +<p>Web内容的源由用于访问它的{{Glossary("URL")}} 的方案(协议),主机(域名)和端口定义。只有当方案,主机和端口都匹配时,两个对象具有相同的起源。</p> + +<p>某些操作仅限于同源内容,而可以使用 <a href="/zh-CN/docs/Glossary/CORS">CORS</a> 解除这个限制。</p> + +<h2 id="同源的例子">同源的例子</h2> + +<table class="standard-table"> + <tbody> + <tr> + <td style="width: 50%;"><code>http://example.com/app1/index.html</code><br> + <code>http://example.com/app2/index.html</code></td> + <td style="width: 50%;">same origin because same scheme (<code>http</code>) and host (<code>example.com</code>)</td> + </tr> + <tr> + <td style="width: 50%;"><code>http://Example.com:80</code><br> + <code>http://example.com</code></td> + <td style="width: 50%;">same origin because a server delivers HTTP content through port 80 by default</td> + </tr> + </tbody> +</table> + +<h2 id="不同源的例子">不同源的例子</h2> + +<table class="standard-table"> + <tbody> + <tr> + <td style="width: 50%;"><code>http://example.com/app1</code><br> + <code>https://example.com/app2</code></td> + <td>different schemes</td> + </tr> + <tr> + <td style="width: 50%;"><code>http://example.com</code><br> + <code>http://www.example.com</code><br> + <code>http://myapp.example.com</code></td> + <td style="width: 50%;">different hosts</td> + </tr> + <tr> + <td style="width: 50%;"><code>http://example.com</code><br> + <code>http://example.com:8080</code></td> + <td style="width: 50%;">different ports</td> + </tr> + </tbody> +</table> + +<h2 id="了解更多">了解更多</h2> + +<p>详细信息,请看<a href="https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Same_origin_policy_for_JavaScript" title="/en-US/docs/Web/JavaScript/Same_origin_policy_for_JavaScript">同源策略</a>。</p> |