![]() |
|
|
UI Tips
Activating ActiveX Controls with JavaScript
For the past couple of years, Microsoft has been locked in
legal battles with a company named Eolas
Technologies. Michael Doyle, formerly of the
The second interaction model, the one that simply displays a tooltip, is essentially an inactive ActiveX control. This inactive control will still perform actions that do not require user interaction, but will not allow user interaction until the control itself is activated. Functionality lost in inactive controls includes mouse events, such as onClick, or interactions from the keyboard. For example, a Windows Media movie would still play; however, the user would not be able to click pause without first activating the control.
Temporary Solution Currently, Microsoft has released a compatibility update that resets Internet Explorer back to the previous mode of handling ActiveX controls. This was provided as a mechanism to allow large organizations time to test new solutions and deploy these solutions. You can find this temporary solution at http://support.microsoft.com/kb/917425. However, one thing to note is that this will only be a fix until the update cycle this month, at which point the new changes will be brought into effect and will then be permanent.
Permanent Solution One thing not covered in the patent was the ability to load an ActiveX object from an external JavaScript file. When loading from an external JavaScript file, the Web browser will not display the dialog box or the control activation. While this solution is a little extra work for the developer, 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 using JavaScript. You have to explicitly separate the logic into a separate .js file in order to get this to work.
One method to activate your ActiveX control is to use document.write to load the control dynamically. For instance, if I wanted to load a flash movie, the code may look something like this:
//JavaScript File "JSLoadExternal.js"
document.write('<object>'); document.write('<param name="URL" value="timeline4.swf">'); document.write('<param name="autostart" value="-1">'); document.write('"timeline4.swf" width="800" height="800"> </embed>'); document.write('</object>');
The corresponding HTML code would look something like this:
<html> <head> </head> <body> <div id="FlashDiv"> <script src="JSLoadExternal.js"></script> </div> </body> </html>
Rather than have multiple JavaScript files to load multiple different ActiveX objects, you may find it better to actually have a generic call inside the JavaScript file that you can call and input parameters to dynamically create the ActiveX object. For instance, a method that looks something like this:
//JavaScript File "JSLoadExternal.js"
function RunActiveX(DivID, Movie, Width, Height ) { var divTag = document.getElementById(DivID);
divTag.innerHTML = "<div><object><param name='URL' value = '" + Movie + "'><param name='autostart' value='-1'><embed src = '" + Movie + "' width =
'" + Width + "' Height = '" + Height +" '></embed></object>";
}
The corresponding HTML code might look something like this:
<html> <head> <script src="./externalJS.js" language = "JavaScript"></script>
</head>
<body> <div id="ReplaceWithFlash"> <div> ReplaceMe </div> </div> <script language = JavaScript> RunActiveX("ReplaceWithFlash", "./timeline4.swf", "800", "800"); </script> </body> </html>
Conclusion These are just a few examples of how you can provide workarounds for the problems caused by the Eolas lawsuit. Microsoft, Apple, and Adobe have provided resources on ways to solve the problems introduced by this lawsuit for their technologies. In closing, if you want to provide the same user-experience that your end users are accustomed to, then you are going to have to follow the above mentioned methods to achieve it.
Resources
Andrew Flick is Product Manager - NetAdvantage Windows Forms Technologies & TestAdvantage for Infragistics, Inc. Prior to joining Infragistics, Andrew played an avid role in presenting on emerging .NET technologies throughout the Midwest to a variety of User Groups as well as numerous Student Groups. As an active member of the INETA Academic Committee, Andrew has authored content on building successful User Groups, as well as numerous white papers on building an effective community. A Microsoft MVP, Andrew joined Infragistics in July of 2004 as a Technology Evangelist, where he was responsible for the creation of reference applications and authoring .NET technology articles for industry leading publications, as well as the world wide delivery of Infragistics’ Technology demonstrations. Andrew currently serves as Infragistics Product Manager for NetAdvantage Windows Forms Technologies & TestAdvantage. As product manager, he spearheads the product management and strategies of Infragistics Windows Forms Product Lines — from establishing the direction through delivery. Working directly with the Director of Development, he sets the direction, plans, and manages product development. Contact Andrew at mailto:andrew@infragistics.com.
Anthony Lombardo is
Product Manager of NetAdvantage - ASP.NET Technologies for Infragistics, Inc.,
and is responsible for spearheading product management and strategies for
Infragistics’ ASP.NET product line, working directly with the Director of
Engineering to set the direction, plan, and manage product development. Prior
to joining Infragistics, Anthony served as a Network Administrator for
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||