Symptom:
When you access the Dynamic
Web TWAIN object, sometimes you get the object undefined message.
Cause:
Dynamic Web TWAIN (DWT) is called before it is fully initialized.
Resolution:
To solve this issue, please make sure Dynamic Web TWAIN finish the initiation
when it is called. You can use a time interval (such as 500ms) to wait until
Dynamic Web TWAIN is ready to be called.
In
our online demo, we use following method test if “online_demo_scan.aspx” plug
is fully initialized when the demo page is loaded. In other project, this issue
can be solved similarly:
var seed;//Set a global variable for time interval
function Pageonload() {
/*
Initialize the webpage, do not call Dynamic Web TWAIN directly
*/
seed =
setInterval(ControlDetect, 500);//Wait 500ms after
opening the webpage,
call “ControlDetect” function
}
function ControlDetect() {
if
(WebTWAIN.ErrorCode == 0) {//Here we use “WebTWAIN.ErrorCode”
to determine if the object is fully initialized
clearInterval(seed); //If DWT is fully initialized, clear the interval
/*
Here you can write the code to control DWT object
*/
}
timeout = setTimeout(function
() { }, 10);//If the initiation of DWT is not
ready, retry after 10ms
}
