Activating ActiveX Controls with JavaScript
Andrew Flick and Anthony Lombardo demonstrate how to activateActiveX controls with JavaScript.
October 30, 2009
For the past couple of years, Microsoft has been locked inlegal battles with a company namedEolasTechnologies. For more information on ActiveX, see "Activating ActiveX Controls with JavaScript." Michael Doyle, formerly of the Universityof California, owns a patentthat defines how ActiveX controls such as QuickTime, Flash, Media Player, andothers are displayed in the browser. The patent was awarded in November of 1998and has been a source of dispute for many years now. As of April 11th,Microsoft distributed a security update via Automatic Update that disallowsinteraction with ActiveX controls unless they are enabled. The current defaultinteraction model for some ActiveX controls is to display the following dialogbox, or for others a tooltip instructing the user to click the control:
The second interaction model, the one that simply displaysa tooltip, is essentially an inactive ActiveX control. This inactive controlwill still perform actions that do not require user interaction, but will notallow user interaction until the control itself is activated. Functionalitylost in inactive controls includes mouse events, such as onClick, orinteractions from the keyboard. For example, a Windows Media movie would stillplay; however, the user would not be able to click pause without firstactivating the control.
Temporary Solution
Currently, Microsoft has released a compatibility updatethat resets Internet Explorer back to the previous mode of handling ActiveXcontrols. This was provided as a mechanism to allow large organizations time totest new solutions and deploy these solutions. You can find this temporarysolution at http://support.microsoft.com/kb/917425.However, one thing to note is that this will only be a fix until the updatecycle this month, at which point the new changes will be brought into effectand will then be permanent.
Permanent Solution
One thing not covered in the patent was the ability toload an ActiveX object from an external JavaScript file. When loading from anexternal JavaScript file, the Web browser will not display the dialog box orthe control activation. While this solution is a little extra work for thedeveloper, the end result will be exactly what the end user has come to expect.Keep in mind that you can t simply load the ActiveX object inline usingJavaScript. You have to explicitly separate the logic into a separate .js filein order to get this to work.
One method to activate your ActiveX control is to usedocument.write to load the control dynamically. For instance, if I wanted toload a flash movie, the code may look something like this:
//JavaScript File "JSLoadExternal.js"document.write('');
The corresponding HTML code would look something likethis:
Rather than have multiple JavaScript files to loadmultiple different ActiveX objects, you may find it better to actually have ageneric call inside the JavaScript file that you can call and input parametersto dynamically create the ActiveX object. For instance, a method that lookssomething like this:
//JavaScript File "JSLoadExternal.js"function RunActiveX(DivID, Movie, Width, Height ){ var divTag = document.getElementById(DivID); divTag.innerHTML = "";}
The corresponding HTML code might look something likethis:
ReplaceMe
Conclusion
These are just a few examples of how you can provideworkarounds for the problems caused by the Eolas lawsuit. Microsoft, Apple, andAdobe have provided resources on ways to solve the problems introduced by thislawsuit for their technologies. In closing, if you want to provide the sameuser-experience that your end users are accustomed to, then you are going tohave to follow the above mentioned methods to achieve it.
Resources
Adobe/Macromedia: http://www.adobe.com/devnet/activecontent/
Eolas Technologies: http://www.eolas.com/
Andrew Flick isProduct Manager - NetAdvantage Windows Forms Technologies & TestAdvantagefor Infragistics, Inc. Prior to joining Infragistics, Andrew played an avidrole in presenting on emerging .NET technologies throughout the Midwest to avariety of User Groups as well as numerous Student Groups. As an active memberof the INETA Academic Committee, Andrew has authored content on buildingsuccessful User Groups, as well as numerous white papers on building aneffective community. A Microsoft MVP, Andrew joined Infragistics in July of2004 as a Technology Evangelist, where he was responsible for the creation ofreference applications and authoring .NET technology articles for industryleading publications, as well as the world wide delivery of InfragisticsTechnology demonstrations. Andrew currently serves as Infragistics ProductManager for NetAdvantage Windows Forms Technologies & TestAdvantage. Asproduct manager, he spearheads the product management and strategies ofInfragistics Windows Forms Product Lines from establishing the directionthrough delivery. Working directly with the Director of Development, he setsthe direction, plans, and manages product development. Contact Andrew at mailto:[email protected].
Anthony Lombardo isProduct Manager of NetAdvantage - ASP.NET Technologies for Infragistics, Inc.,and is responsible for spearheading product management and strategies forInfragistics ASP.NET product line, working directly with the Director ofEngineering to set the direction, plan, and manage product development. Priorto joining Infragistics, Anthony served as a Network Administrator for NorthBrunswick Board of Education and worked for RutgersUniversity in their technicalsupport division. Since beginning his career with Infragistics in 2000, Anthonyhas been involved with every aspect of the development cycle, including playinga key role in the creation of the Presentation Layer Framework for ASP.NET,assisting in the creation and implementation of Infragistics Visual Studio 2005project plan, and determining the product feature set for NetAdvantage 2005 forVisual Studio 2005. Contact Anthony at mailto:[email protected].
About the Author
You May Also Like