<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>New Page 1</title>
</head><body>
<span style="background-color:red" id=aaa ></span>
<br><input type=button value=test onclick="testFun();">
</body></html>
<script>
function testFun()
{
var tempValue=0;
for(var i=0;i<10000;i++)
{
tempValue+=i;
aaa.style.width=(i/100)+"%";
if((i%100)==0)
  window.showModalDialog("about:"+(i/100)+"%"+"<script>window.setTimeout('window.close()',10)<\/sc"+"ript>","","dialogHeight:100px;dialogWidth:100px;");}
}</script>

解决方案 »

  1.   

    或:<html><head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>New Page 1</title>
    </head><body>
    <span style="background-color:red" id=aaa ></span>
    <br><input type=button value=test onclick="testFun();">
    </body></html>
    <script>
    function testFun()
    {
    var tempValue=0;
    for(var i=0;i<10000;i++)
    {
    tempValue+=i;
    aaa.style.width=(i/100)+"%";
    if((i%100)==0)
      window.showModalDialog("a1.html?"+(i/100),"","dialogHeight:100px;dialogWidth:100px;");}
    }</script>------
    a1.html:
    <html>
    <script language=javascript> 
    window.setTimeout("window.close();",10);
    </script>
    </html>
      

  2.   

    楼上的方法其实我已经说过了,也就是暂停循环的方法.这样的缺点是本来循环只要3秒就可以完成,但是这样一次次的暂停,有可能这个循环需要6秒,效率上不是很好.
    查过MSDN,好像我的想法不可能,浏览器必定是"循环更改,一次显示".