同源策略

源(origin)就是协议、域名和端口号。
以上url中的源就是:http://www.company.com:80
若地址里面的协议、域名和端口号均相同则属于同源。
以下是相对于 http://www.a.com/test/index.html 的同源检测
http://www.a.com/dir/page.html ----成功
http://www.child.a.com/test/index.html ----失败,域名不同
https://www.a.com/test/index.html ----失败,协议不同
http://www.a.com:8080/test/index.html ----失败,端口号不同

猜你喜欢

转载自blog.csdn.net/Joker__chan/article/details/79994173