您的位置:首页 > Web前端 > JavaScript

Javascript跨域

2016-02-19 11:50 791 查看

Javascript跨域

这几天整理了Javascript跨域的东西,终于比较完整了



附上CORS代码:

1 function createCORSRequest(method, url) {
2    var xhr = new XMLHttpRequest();
3    if ("withCredentials" in xhr) {
4       xhr.open(method, url, true);
5    } else if (typeof XDomainRequest!= "undefined") {
6       xhr = new XDomainRequest();
7       xhr.open(method, url);
8    } else {
9      // 否则,浏览器不支持CORS
10      xhr = null;
11    }
12    return xhr;
13 }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: