Is the Sleep operation no longer used in VBscript?

后端 未结 3 1600
清歌不尽
清歌不尽 2020-12-02 01:14

The \"Sleep\" command as stated in many places over the internet (including here on this forum) DOES NOT WORK. Is it now an obsolete command?

I am writing the VBScri

3条回答
  •  醉梦人生
    2020-12-02 01:22

    When run from a browser, VBScript code does not have a Wscript object. This is only for stand-alone VBS. As such, Wscript.Sleep isn't obsolete, it just doesn't work in a browser without a work around.

    This thread suggests a potential work around. The rest of this post comes from the entry by mayayana on the linked page:

    If your security can allow WScript.Shell to run you can do it this way -

    Script sub in webpage:

    
    

    In the same folder as the webpage, put a file named sleeper.vbs and put this code into it:

    Dim Arg
    on error resume next
    Arg = WScript.Arguments(0) * 1000
    WScript.sleep Arg
    

    You can then call something like:

    Sleep 5 '-- pauses 5 seconds.

提交回复
热议问题