setInterval函数IE计时不准问题



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML>
<HEAD>
<title>WebForm5</title>

<style>
    .dv1{
        position: absolute;
        border: 1px solid blue;
        left: -800px;
    }
    .dv1 li{
        float:left;
    }
</style>

<script>


</script>
</HEAD>
<body>
    <div id="do1" class="dv1"></div>
    <input type="button" value="start" onclick="startfn();" />
    <input type="button" value="stop" onclick="stopfn();" />
    setInterval函数IE计时不准问题
    
    代码见script标签.运行结果为:
    
    半分钟  FF执行918次  IE 716次  chrome 900次 safari 926次 opera 930次(IE差了大约200毫秒)
    
    半分钟应该执行的次数为30000/32 = 937.5次, IE差太多了
</body>
</HTML>

<script>
    var _timer;
    function startfn(){
        var _test = 1;
		var mm = 50;
        _timer = window.setInterval(function(){
                //随便胡乱写的代码,不必观看
                document.title = _test++;
				var i,j,k,l,m,n;
				i=[10,10];
				j = i;
				k = j;
				l = k;
				m = l;
				n = m;
				if(j == i||k == j||l == k||m == l||n == m){
				    while(mm>0){
				        mm--;
				    }
				}
			},32);
    }
    function stopfn(){
        window.clearInterval(_timer);
    }
    
    
    
</script>


你可能感兴趣的:(IE,chrome,Opera,J#,Safari)