none
problem with window.setTimeout vbscript in an html page

    Question

  • I have vbscript code below but ExtHubPort is an object and Hotplug is a method on ExtHubPort but my problem is how to use setTimeout on in vbscript to call this line of code because GenericHIDDSFDev is the argument to hotplug:

    Set ID = window.setTimeout "ExtHubPort.HotPlug "+GenericHIDDSFDev,2000,"vbscript"

    If anyone has an alterative method to use im trying to use equivilent of WScript.sleep in an html page.


    Once you eliminate the impossible, whatever remains, no matter how improbable, must be the truth. - "Sherlock holmes" "speak softly and carry a big stick" - theodore roosevelt. Fear leads to anger, anger leads to hate, hate leads to suffering - Yoda

    Thursday, April 05, 2012 2:31 PM

Answers

  • First, setInterval does not return an interval pointer like setInterval, so the SET ID= part is not needed.  I'm surprised it didn't throw a syntax error.  Second, I'd wrap the call into a subroutine and make the GenericHIDDSFDev variable a global in your script section.  Otherwise, the value will be hard code at the time the setTimeout is invoked, not the value when the subroutine actually gets called.  I don't know if that makes a difference, but it might.

    <script language=vbs>
    Dim GenericHIDDSFDev, ExtHubPort
    '
    sub window_onload
    ' the rest of your script including instantiation of ExtHubPort
      window.setTimeout "CallHotPlug", 2000, "vbscript"
    end sub
    '
    sub CallHotPlug
      ExtHubPort.HotPlug  GenericHIDDSFDev
    end sub
    </script>


    Tom Lavedas



    Thursday, April 05, 2012 2:57 PM

All replies

  • First, setInterval does not return an interval pointer like setInterval, so the SET ID= part is not needed.  I'm surprised it didn't throw a syntax error.  Second, I'd wrap the call into a subroutine and make the GenericHIDDSFDev variable a global in your script section.  Otherwise, the value will be hard code at the time the setTimeout is invoked, not the value when the subroutine actually gets called.  I don't know if that makes a difference, but it might.

    <script language=vbs>
    Dim GenericHIDDSFDev, ExtHubPort
    '
    sub window_onload
    ' the rest of your script including instantiation of ExtHubPort
      window.setTimeout "CallHotPlug", 2000, "vbscript"
    end sub
    '
    sub CallHotPlug
      ExtHubPort.HotPlug  GenericHIDDSFDev
    end sub
    </script>


    Tom Lavedas



    Thursday, April 05, 2012 2:57 PM
  • probably thought i was going to have to do that but was trying to see if it was possible to execute directly oh well thank you!

    Once you eliminate the impossible, whatever remains, no matter how improbable, must be the truth. - "Sherlock holmes" "speak softly and carry a big stick" - theodore roosevelt. Fear leads to anger, anger leads to hate, hate leads to suffering - Yoda

    Thursday, April 05, 2012 3:24 PM