我的部分代码如下:<script language="jscript">// 进度显示函数,我在循环中调用的
function Step(nValue)
{
    document.all("tdProgress").width = nValue.toString() + "%";
    document.all("divText1").innerText = "正在汇总,已完成";
    document.all("divText2").innerText = nValue.toString();
    document.all("divText3").innerText = "%";    document.all("txtTemp").value = nValue;
}// 我的工作函数
function btnSum_onclick()
{
    //
    // (主要代码摘抄如下)
    //    for (i = 0; i < parseInt(document.all("txtDeptNum").value); i ++)
    {
        id = "dgUnit__ctl" + (parseInt(i) + 2).toString() + "_chkSelect";        if (document.all(id).checked == true)
        {
            strFileName = strTempDir
                        + "\\"
                        + "DB_" + document.all("txtCaseID").value
                        + "_" + vDeptIDs[i]
                        + ".HTM"            strURL = "/BudgetEdit/fmGetData.aspx?Name=nt-zzm&Kind=1&CaseID=" + document.all("txtCaseID").value
                    + "&Version=" + document.all("txtVersion").value
                    + "&DeptID=" + vDeptIDs[i];            // 文件下载
            if (! Download(strURL, strFileName)) return false;            index = parseInt(index) + 1;     // 此处调用
            Step((index * 40) / selNum);
        }
    }    // 此处调用
    Step(40);    index = 0;    for (i = 0; i < parseInt(document.all("txtDeptNum").value); i ++)
    {
        id = "dgUnit__ctl" + (parseInt(i) + 2).toString() + "_chkSelect";        if (document.all(id).checked == true)
        {
            strFileName = strTempDir
                        + "\\"
                        + "DB_" + document.all("txtCaseID").value
                        + "_" + vDeptIDs[i]
                        + ".HTM"            var objSheet = new ActiveXObject("OWC.Spreadsheet");            objSheet.DataType = "HTMLData";
            objSheet.HTMLURL = strFileName;     //
    // (数据处理,略)
    //     objSheet = null;

            index = parseInt(index) + 1;     // 此处调用
            Step((index * 60) / selNum + 40);
        }
    }    // 此处调用
    Step(100);}

解决方案 »

  1.   

    我的第一个循环是下载N个单位的数据文件,如果改成异步,或许进度能出来.第二个循环是对N个单位的数据处理,比较复杂,没有办法异步处理,我估计
    是由于IE没有机会处理消息,导致进度无法显示,就像我们在VB中如果做长
    时间循环都要调用DoEvent,暂时让Window进行消息处理一样.但在IE中又
    如何实现呢!请指正!
      

  2.   

    兄弟,你的代码还实在有点复杂,还是到Javascript组问问吧!
      

  3.   

    there is no asynchronous mode to run javascript in a browser, try to use setTimeout to give up your execution from time to time