跨域
同源策略
协议 域名 端口 同域
为什么浏览器不支持跨域
cookie LocalStorage
DOM元素也有同源策略 iframe
ajax 也不支持跨域
实现跨域
- jsonp
- cors
- postMessage
- document.domain
- window.name
- location.hash
- http-proxy
- mgox
- websocket
jsonp
利用script标签的跨域性
只能发送get请求 不支持post put delete
不安全 xss攻击, 不采用,返回可能含有script标签
CROS
浏览器屏蔽了跨域响应
如果想要允许这种跨域请求,可以在服务器返回response头信息中添加以下字段来限定那些地址的跨域请求可以被允许:
- Access-Control-Allow-Origin : htt[