同源策略限制了从同⼀个源加载的⽂档或脚本如何与来⾃另⼀个源的资源进⾏交互。这是⼀个⽤于隔离潜在恶意⽂件的
重要安全机制。
同源是指"协议+域名+端⼝"三者相同,即便两个不同的域名指向同⼀个ip地址,也⾮同源。
下表给出了http://store.company.com/dir/page.html。
| URL | 结果 | 原因 |
|---|---|---|
| http://store.company.com/dir2/other.html | 成功 | 只有路径不同 |
| http://store.company.com/dir/inner/another.html | 成功 | 只有路径不同 |
| https://store.company.com/secure.html | 失败 | 不同协议(https和http) |
| http://store.company.com:81/dir/etc.html | 失败 | 不同端口号(http://80是默认的) |
| http://news.company.com/dir/other.html | 失败 | 不同域名(new和store) |
| 浏览器中的大部分内容都受同源策略限制的,但是以下三个标签可以不受限制: |

