I am trying to make a client-side vbscript sleep but can't do it w/o pinning the cpu
The Code is below, pretty straight forward, but I get the following error:
error: object doesn't support this property or method 'Wscript.Sleep'
***********code
<html>
<head>
<SCRIPT LANGUAGE="vbscript" >
function bSleep()
document.All.whatsup.inner
HTML = "I'm sleepy"
Set WScript = CreateObject("WScript.Shel
l")
WScript.Sleep 2000
document.All.whatsup.inner
HTML = "Done sleeping"
end function
</script>
<body onload="call bSleep()">
<div id="whatsup"></div>
</body>
</html>
***********end code
To workaround, I swap out the wscript.sleep and use a loop, but it pins the cpu and that isn't acceptable because I am sleeping so other stuff can happen in the background. Here is the loop code that pins the cpu:
***********code snip (loop1)
StartTime=Now()
Do While Now() < StartTime + 8.0 / (3600.0 * 24.0)
' loop
Loop
***********end code snip
I also tried this loop:
***********code snip (loop2)
Do While Not oBrowser.readyState = READYSTATE_COMPLETE
' sometimes this fails--failure is unacceptable
Loop
***********end code snip
FYI, You're probably wondering how the oBrowser object got involved in loop2 (above). If you want some background on the context. . . I am using this sleep code while a internetexplorer object navigates. I've found that looping structure #2 doesn't work when a site is a slow loader, i.e., it will say the readystate is complete, but it really isn't! Additionally, loop2 pins the cpu too and the spawned browser can't download anything.
Below is the complete code for my application if you want to put it all in context run this code below. For this to work you have to set your ie default tools-options-security-def
ault level to 'low'
***********all code
<html>
<head>
<SCRIPT LANGUAGE="vbscript" >
function bUpdateAll()
document.All.whatsup.inner
HTML = "starting"
sUrl = "
http://www.aspfree.com"
const READYSTATE_COMPLETE = 4
on error resume next
Set oBrowser = CreateObject("InternetExpl
orer.Appli
cation")
if err.number <> 0 then
document.All.whatsup.inner
HTML = "set your ie default tools-options-security-def
ault level to 'low'"
exit function
end if
on error goto 0
oBrowser.Width = 600
oBrowser.Height = 400
oBrowser.Left = 50
oBrowser.Top = 50
oBrowser.Visible = true
oBrowser.Silent = true
oBrowser.Navigate(sUrl)
StartTime=Now()
Do While Not oBrowser.readyState = READYSTATE_COMPLETE
' loop
Loop
set oBrowser = nothing
document.All.whatsup.inner
HTML = "done"
end function
</script>
</head>
<body onload="call bUpdateAll()">
<div id="whatsup"></div>
</body>
</html>
***********end all code
Start Free Trial