为什么这程序就不能按我想象中的那样运行呢?
我就想点两下鼠标,看下时间间隔.
结果就做成了一个CPU100%占用的病毒,这是个改进版,以前那个弹窗弹到死.
<!DOCTYPE html><html><head><title>time</title><script type="text/javascript" src="xxxx.js"></script><meta http-equiv="Cache-Contorl" content="no-cache"/></head><body onload="time();"></body></html>
function time(){ var startTime=new Date(); var endTime=new Date(); var n=new Date(); var i; for(i=0;i<2;){ onmousedown=function(){if(i==0){startTime=n.getTime();i=1;}}; onmousedown=function(){if(i==1){endTime=n.getTime();i=2;}}; } n=endTime-startTime; alert(n); }<!DOCTYPE HTML><html> <head> <meta charset="gb2312" /> <title></title> <style> </style> </head> <body> <script> var times = []; document.onclick = function(){ if( !times.length ){ var t = new Date; times.push(t); }else{ var t = new Date; times.push(t); alert( '间隔 ' + (times[1] - times[0]) / 1000 + ' 秒' ); times.length = 0; // 情况记录 } } </script> </body></html>