Waiting for the WebViewer to be ready

When loading a web viewer with a large amount of code it takes some time to become ready for use. People usually insert a delay for 1 second perhaps to give it time. By putting in a known string at the end of my HTML, I can run a loop checking for this string before trying to use the web viewer. Seems to work well.

# wait until the ObjectAttribute is returned with the expected trigger text of ***JS-FOUND*** this text is at the end of the JS

Set Variable [ $count ; Value: 1 ]

Loop

Set Variable [ $wvcontents ; Value: GetLayoutObjectAttribute ( “wvname” ; "content" ) ]

Set Variable [ $IsReady ; Value: PatternCount ( $wvcontents ; "***JS-FOUND***" ) ]

Exit Loop If [ $IsReady or $count>100 ]

Set Variable [ $count ; Value: $count+1 ]

Pause/Resume Script [ Duration (seconds): .01 ]

End Loop