下面程序中为什么暂停程序无效,请各位帮忙修正!!
  function PrintImage()
   {
      var tiff;
      tiff="",num="<%=printnum%>";
      for(var i=1;i<=num;i++)
      {
       tiff= "tiff" + i; 
       if (document.getElementById(tiff).GetValue(9)==2480)
         {
        var WshShell = new ActiveXObject("WScript.Shell");
              WshShell.Run("cmd /k  c://2.bat");
             } 
             else if (document.getElementById(tiff).GetValue(9)==4961)
         {
        var WshShell = new ActiveXObject("WScript.Shell");
              WshShell.Run("cmd /k  c://3.bat");
             } 
     try {
        Thread.sleep(5000);                 //由类名调用
      } catch (InterruptedException e) {
        return;
    document.getElementById(tiff).Print(4);
      }
    }

解决方案 »

  1.   

    JS中有这个类?我记得JS中没有sleep的。
      

  2.   

    js没有让程序暂停的函数   只能用  setTimeout 和 setInterval 来延迟执行
      

  3.   

     Thread.sleep(5000);     
    =>
     WScript.sleep(5000);
      

  4.   

    2楼正解
    不能使用Java的语法来用吧
      

  5.   


    function pause(){
        alert('我要暂停了!');
        setTimeout(function(){
        alert('我暂停了吧?');
        },5000); 
    }
      

  6.   

    找了一段代码,能实现 sleep效果,希望大家在这个基础能帮我修改不弹出“sleep”5秒后执行(我对js一点不熟),谢谢各位!!
    function Sleep(obj,iMinSecond)  
     {  
        if (window.eventList==null)  
        window.eventList=new Array();  
        var ind=-1;  
        for (var i=0;i<window.eventList.length;i++)  
        {    
         if (window.eventList[i]==null)  
         {  
          window.eventList[i]=obj;     
          ind=i;    
         break;    
         }  
        }  
        if (ind==-1)  
        {    
        ind=window.eventList.length;    
         window.eventList[ind]=obj;  
        }  
        setTimeout("GoOn(" + ind + ")",iMinSecond);  
     }  
     function GoOn(ind)  
     {  
        var obj=window.eventList[ind];  
       window.eventList[ind]=null;  
        if (obj.NextStep) obj.NextStep();  
        else obj();  
     }    
     function Test()  
      

  7.   

    var t=setTimeout("alert('5 seconds!')",5000) 
    这句不能达到我的效果,程序没有进入sleep状态
      

  8.   

    setTimeout 和 setInterval 来延迟执行
      

  9.   


    没有起到暂停效果,我需要8楼代码效果,但要去除弹出框“sleep”
      

  10.   

    更正下,8楼代码我没有贴完全,正确如下:
     function Sleep(obj,iMinSecond)  
     {  
        if (window.eventList==null)  
        window.eventList=new Array();  
        var ind=-1;  
        for (var i=0;i<window.eventList.length;i++)  
        {    
         if (window.eventList[i]==null)  
         {  
          window.eventList[i]=obj;     
          ind=i;    
         break;    
         }  
        }  
        if (ind==-1)  
        {    
        ind=window.eventList.length;    
         window.eventList[ind]=obj;  
        }  
        setTimeout("GoOn(" + ind + ")",iMinSecond);  
     }  
     function GoOn(ind)  
     {  
        var obj=window.eventList[ind];  
       window.eventList[ind]=null;  
        if (obj.NextStep) obj.NextStep();  
        else obj();  
     }    
     function Test()  
     {  
        alert("sleep");  
        Sleep(this,10000);  
        this.NextStep=function()  
        {  
        alert("continue");  
        }  
     }     
     Test(); 
      

  11.   

    不要弹出sleep???<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
     <HEAD>
      <TITLE> New Document </TITLE>
      <META NAME="Generator" CONTENT="EditPlus">
      <META NAME="Author" CONTENT="">
      <META NAME="Keywords" CONTENT="">
      <META NAME="Description" CONTENT="">
     </HEAD> <BODY>
      <SCRIPT LANGUAGE="JavaScript">
      <!--
    function Sleep(obj,iMinSecond)  
     {  
        if (window.eventList==null)  
        window.eventList=new Array();  
        var ind=-1;  
        for (var i=0;i<window.eventList.length;i++)  
        {    
         if (window.eventList[i]==null)  
         {  
          window.eventList[i]=obj;     
          ind=i;    
         break;    
         }  
        }  
        if (ind==-1)  
        {    
        ind=window.eventList.length;    
         window.eventList[ind]=obj;  
        }  
        setTimeout("GoOn(" + ind + ")",iMinSecond);  
     }  
     function GoOn(ind)  
     {  
        var obj=window.eventList[ind];  
        window.eventList[ind]=null;  
        if (obj.NextStep) obj.NextStep();  
        else obj();  
     }    
     function Test()  
     {  
        //alert("sleep");  
        Sleep(this,5000);  
    document.write("此方法开始沉睡5秒");
        this.NextStep=function()  
        {  
            alert("continue");  
    document.write("方法开始了,沉睡结束");
        }  
     }     
     Test(); 
      //-->
      </SCRIPT>
     </BODY>
    </HTML>
      

  12.   

    document.write("此方法开始沉睡5秒");
     document.write("方法开始了,沉睡结束");
    都屏蔽掉!在语句前加//
    //document.write("此方法开始沉睡5秒");
    //document.write("方法开始了,沉睡结束");汗啊~~~LZ貌似对js一点都不了解!
      

  13.   

    问题的关键是,按照上述做法后
    程序并没有得到暂停,按照12楼做法效果是:当点击弹出框“sleep”,程序会继续,不点则停留在那个界面上
      

  14.   

    那个sleep是不是叫线程里面的吧,
    js没有让程序暂停的函数 只能用 setTimeout 和 setInterval 来延迟执行