Custom ActiveX Event for IE 11

Microsoft’s IE 11 has been released for a while now. The new version of Internet Explorer, which has been redesigned with many new features, is excellent on performance. However, it removes some old features that may cause compatibility problems for ActiveX based web application, such as the document scanning online demo for Dynamic Web TWAIN. This demo is designed to scan document pages from an automatic document feeder, and upload them through FTP or a web server. Because IE 11 has removed support for the attachEvent method, some custom events based on this method have to be changed.

In the online_demo_scan.aspx, add one line at the bottom of the source.

<script for='11' event='11'></script> // add this line
<input name="SessionID" type="hidden" id="SessionID" value="5byetx55sp4qna55tfsviaz0" />
</body>
</html>

Then open dynamsoft.webtwain.initiate.js, create a conversion function, and add some code for IE 11.

Function.prototype.getName = function() {
        return this.name || this.toString().match(/function\s*([^(]*)\(/)[1]
}
SWebTwain.prototype._createControl = function() {
        var varDWTContainer;
        var objString = "<div id ='" + this._strDWTInnerContainerID + "' style='position: relative;width:" + this._iWidth + "px; height:" + this._iHeight + "px;'>";
        // For IE, render the ActiveX Object
        if (Dynamsoft.Env._bInIE) {
            objString += "<object classid='clsid:" + D.DWTProduct._strPROCLASSID + "' style='display:none;'><param name='LPKPath' value='" + D.DWTProduct._strLPKPath + "'/></object>";
            ua = (navigator.userAgent.toLowerCase());
            // Event for IE 11
            if (ua.indexOf('trident') != -1 && ua.indexOf('msie') == -1) {
                if (this._onPostTransfer != '')
                    objString += "<script for='" + this._strObjectName + "' event='onPostTransfer'> " + this._onPostTransfer.getName() + "(); </script>";

With a little bit of change, the demo for controlling a scanner can now work in IE 11.

Subscribe Newsletter

Subscribe to our mailing list to get the monthly update.

Subscribename@email.com