Sleep
Description
Suspends (sleeps) script execution for a specified timeout or until a passed callback function returns true. This is an efficient way to wait for an event without burning CPU cycles.
Syntax
printing.Sleep(timeout, [callback])
Parameter |
Description |
timeout |
(Number) the timeout in milliseconds. |
callback |
(Function) the optional pointer to the function to be periodically called within the Sleepmethod. When the function returnstrue, the sleep is canceled. |
Return Value
Returns true if the sleep was canceled by a callback function.
Applies To
printing
Example
The following code snippet navigates a frame to a file then prints its content:
<script>
function NavigatePrintFrame(url) {
idFrame.navigate(url);
factory.printing.Sleep(100) // let the navigation start
factory.printing.Sleep(1000*60, IsReady) // sleep for 1 minute or until the document is ready
factory.printing.Print(true, idFrame)
}
function IsReady() {
return idFrame.document.readyState == "complete"
}
</script>
See Also
onafterprint
IsSpooling, Print, WaitForSpoolingComplete