getXSSAjax(function() { //跨域请求
that.ajaxDara(self);
},
(bs_tita.webapi || "http://webapi.tita.com") + "/iframe.html");
//跨域请求
function getXSSAjax(callback, iframeUrl){
// avoid
error of calling many time in initializing page
getXSSAjax.callbacks =
getXSSAjax.callbacks || [];
var frameId =
"_bs_js_xss_"+iframeUrl;
var iframe =
document.getElementById(frameId);
if(!iframe){
iframe =
document.createElement('iframe');
iframe.id = frameId;
iframe.style.display="none";
iframe.src = iframeUrl;
if(iframe.attachEvent){
iframe.attachEvent("onload",
loadHandler);
} else {
iframe.onload =
loadHandler;
}
getXSSAjax.callbacks.push(callback);
document.body.appendChild(iframe);
}else{
if(getXSSAjax.loaded){
callback && callback();
}else{
getXSSAjax.callbacks.push(callback);
}
}
function loadHandler () {
var domainFields =
document.domain.split('.');
var len = domainFields.length;
document.domain=domainFields[len-2]+"."+domainFields[len-1];
getXSSAjax.loaded = true;
$.ajaxPrefilter( function( options )
{
var domain =
iframe.src.split('/').slice(0,3).join('/');
if(options.url.indexOf(domain) == 0){
// used in
ie6
$.support.cors = true;
options.xhr = function(){
var iframeWindow =
iframe.contentWindow;
return iframeWindow.XMLHttpRequest?
new iframeWindow.XMLHttpRequest() : iframeWindow.ActiveXObject ? new
iframeWindow.ActiveXObject("Microsoft.XMLHTTP") : new
iframeWindow.XMLHttpRequest();
};
}
});
for (var i = 0, l=getXSSAjax.callbacks.length; i
< l; i++) {
var callback = getXSSAjax.callbacks.pop();
callback && callback();
};
}
}