Javascript跨域

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

Javascript跨域

附上CORS代码:

Javascript跨域
 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 }  
Javascript跨域
分类: 1.前端基础

本文转自 海角在眼前 博客园博客,原文链接:  http://www.cnblogs.com/lovesong/p/3329692.html ,如需转载请自行联系原作者