evantianx / Bloooooooog

Place to record what I thought and learned
0 stars 0 forks source link

关于JavaScript跨域 #22

Open evantianx opened 7 years ago

evantianx commented 7 years ago

老生常谈的话题,今天来总结一下。

谈到跨域就必须说一说“同源策略”:

所谓同源策略 The same-origin policy restricts how a document or script loaded from one origin can interact with a resource from another origin.

http://store.company.com/dir2/other.html                 //同源                      
http://store.company.com/dir/inner/another.html         //同源
https://store.company.com/secure.html                  //不同源,协议不同
http://store.company.com:81/dir/etc.html              //不同源,端口不同
http://news.company.com/dir/other.html               //不同源,host不同

From Same-origin policy MDN

js中几种实用的跨域方法原理详解