The leading provider of version control solution and TWAIN SDK

How to support multi browsers in one scan page?

Dynamic Web TWAIN works with all mainstream browsers:
  • ActiveX Edition for Internet Explorer (32-bit & 64-bit) on Windows;
  • Plug-in Edition for Firefox, Chrome, Safari and Opera on Windows;
  • Mac Edition for Safari, Chrome, Firefox and Opera on Mac OS X.
Haven't downloaded Dynamic Web TWAIN? Please check the download page.

# Deployment steps


To support all browsers in one scan page, you can detect the browser type and then direct users to the according Dynamic Web TWAIN CAB file (ActiveX edition), .MSI file (Plug-in Edition) and .PKG file (Mac Edition).
  1. For ActiveX Edition, please put .CAB file and .LPK file in your website folder.
  2. For Plugin Edition, please put MSI file (and .XPI if necessary) in your website folder.

    What's the difference between XPI and MSI?
     

    Support Browser (s) 

    Advantage 

    Disadvantage 

     XPIFirefox onlyRecognize by Firefox;
    End users will be prompted automatically to install the missing plug-in
    Awkward upgrade - end users have to manually remove the old XPI in Firefox, restart Firefox, and then install the new XPI
     MSIFirefox, Chrome, Safari and OperaSupport ALL non-IE browsers;
    Easy Upgrade - end users only need to download a newer MSI and install it to finish the ugprade.
    Display a download to prompt end users to manually install missing plug-in
    We recommend you use the MSI file for plugin edition.

  3. For Mac Edition, please put DynamicWebTWAINMacEditionTrial.pkg (DynamicWebTWAINMacEdition.pkg) file in your website folder.
  4. Add all three editions on your scan page and call the controls accordingly.
     Where can I find the LPK, CAB, MSI and PKG files

# Working Sample

    * Dynamic Web TWAIN online demo

    * Local Demo and Visual Studio Demo (Which can be found in the installation folder of Dynamic Web TWAIN).

# Code snippet

Below is the code snippet for your reference:

//=======================
< script
type="text/javascript">
<!--
function ExplorerType()
{
        var ua = (navigator.userAgent.toLowerCase());     

        if (ua.indexOf("msie") != -1) return "IE";
}
  
var WebTWAIN;
// WebTWAIN is the parameter name which represents the plug-ins of all three editions, so that you can use the same code for all browsers.


var strObjectPlugin = "";
    strObjectPlugin = " <embed style='display:inline' id='mainDynamicWebTWAINnotIE' type='Application/DynamicWebTwain-Plugin'";
    if (navigator.userAgent.indexOf("Macintosh") != -1)
{
        strObjectPlugin += "pluginspage='DynamicWebTWAINPluginforMacTrial.pkg'></embed>";
   
}
    else {
       
strObjectPlugin += "
pluginspage='DynamicWebTwain.xpi'></embed>";
   
}
    var strObjectActiveX = "";
   
strObjectActiveX = "   <param name='_cx' value='3784' />";
    strObjectActiveX += "    <param name='_cy' value='4128' />";
    strObjectActiveX += "    <param name='JpgQuality' value='80' />";
    strObjectActiveX += "    <param name='Manufacturer' value='DynamSoft Corporation' />";
   
strObjectActiveX += "    <param name='ProductFamily' value='Dynamic Web TWAIN' />";
    strObjectActiveX += "    <param name='ProductName' value='Dynamic Web TWAIN' />";
    strObjectActiveX += "    <param name='VersionInfo' value='Dynamic Web TWAIN 7.0' />";
   
strObjectActiveX += "    </object>";
   
if (ExplorerType() == "IE" && navigator.userAgent.indexOf("Win64") != -1 && navigator.userAgent.indexOf("x64") != -1)
{
        strObjectActiveX = "<object id='mainDynamicWebTwainIE' codebase='DynamicWebTWAIN/DynamicWebTWAINx64.cab#version=7,0' class='divcontrol' " + "classid='clsid:FFC6F181-A5CF-4ec4-A441-093D7134FBF2' viewastext> " + strObject;
        var objDivx64 = document.getElementById("maindivIEx64");
       
objDivx64.style.display = "inline";
        objDivx64.innerHTML = strObject;
        var obj = document.getElementById("maindivPlugin");
       
obj.style.display = "none";
       
WebTWAIN = document.getElementById("mainDynamicWebTwainIE");
    }//if IE 64 bit, direct users to use DynamicWebTWAINx64.cab

    else if (ExplorerType() == "IE" && (navigator.userAgent.indexOf("Win64") == -1 || navigator.userAgent.indexOf("x64") == -1))
{
        strObjectActiveX = "<object id='mainDynamicWebTwainIE' codebase='DynamicWebTWAIN/DynamicWebTWAIN.cab#version=7,0' class='divcontrol'" + "classid='clsid:FFC6F181-A5CF-4ec4-A441-093D7134FBF2' viewastext> " + strObject;
        var objDivx86 = document.getElementById("maindivIEx86");
       
objDivx86.style.display = "inline";
        objDivx86.innerHTML = strObject;
        var obj = document.getElementById("maindivPlugin");
       
obj.style.display = "none";
       
WebTWAIN = document.getElementById("mainDynamicWebTwainIE");
    }//if IE 32 bit, direct users to use DynamicWebTWAIN.cab

    else
{
        var objDivFF = document.getElementById("mainControlInstalled");
       
objDivFF.innerHTML = strObjectPlugin;
        var obj = document.getElementById("maindivIE");
       
obj.style.display = "none";
        var obj = document.getElementById("maindivPlugin");
       
obj.style.display = "inline";
       
WebTWAIN = document.getElementById("mainDynamicWebTWAINnotIE");
    }

//If the control is not installed, direct the users to download and install the control.
    if (WebTWAIN.ErrorCode != 0)
{
        if (navigator.userAgent.indexOf("Macintosh") != -1)
{
           
document.getElementById("MACmainControlNotInstalled").style.display = "inline";
           
document.getElementById("mainControlInstalled").style.display = "none";
       
}
        else if (ua.match(/chrome\/([\d.]+)/) || ua.match(/opera.([\d.]+)/) ||
ua.match(/version\/([\d.]+).*safari/))
{
           
document.getElementById("mainControlNotInstalled").style.display = "inline";
           
document.getElementById("mainControlInstalled").style.display = "none";
        }
   
}
</script>

// HTML
<div id="dwtcontrol">
<div id="maindivPlugin" >

<div style="display:none;" id="mainControlNotInstalled">
<table id="maintblcontrolnotinstalled"
class="divcontrol">
    <tr>
   
<td
style="text-align:center;vertical-align:middle;">
       
<a href="DynamicWebTWAIN/DynamicWebTWAINPlugInTrial.msi"><strong>Download and install the Plug-in Here</strong></a><br/>
        After the installation, please restart your browser.
   
</td>
   
</tr>
</table>
</div>

<div
style="display:none;" id="MACmainControlNotInstalled">
<table id="MACtblmainControlNotInstalled" class="divcontrol">
   
<tr>
    <td
style="text-align:center;vertical-align:middle;">
       
<a href="DynamicWebTWAIN/DynamicWebTWAINPluginforMacTrial.pkg"><strong>Download
and install the Plug-in Here</strong></a><br/>
        After the installation, please quit and restart your browser. <br/>
        If you are using Safari 5.0, you need to run the browser in 32-bit Mode</a>.<br/>
    </td>
   
</tr>
</table>
</div>

<div id="mainControlInstalled">

</div>

</div>

<div id="maindivIE">
<object classid="clsid:5220cb21-c88d-11cf-b347-00aa00a28331" style="display:none;">
    <param name="LPKPath" value="DynamicWebTWAIN/DynamicWebTwain.lpk" />
</object>
<div id="maindivIEx86" >                                   

</div>
<div id="maindivIEx64" >                                 

</div>
</div>
</div>

//=======================




Article Details

Last Updated
30th o March, 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 (3 votes)

100% thumbs up 0% thumbs down

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