The leading provider of version control solution and TWAIN SDK

Why do I get “Undefined” error message when using Dynamic Web TWAIN object?

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
WebTWAIN;// Set a global variable for the DWT object
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
}

 




Article Details

Last Updated
10th o January, 2012

Would you like to...

Print this page Print this page

Email this page Email this page

Post a comment Post a comment

Subscribe me

Add to favorites Add to favorites

Remove Highlighting Remove Highlighting

Edit this Article

Quick Edit

Export to PDF

User Opinions (0 votes)

No users have voted.

How would you rate this answer?



Thank you for rating this answer.

Related Articles

No related articles were found.

Attachments

No attachments were found.

Visitor Comments

No visitor comments posted. Post a comment

Post a comment

To post a comment for this article, simply complete the form below. Fields marked with an asterisk are required.
   Name:
   Email:
* Comment:
* Enter the code below:
 

Continue