Created:
4/18/2006 8:36:05 AM

Author:
Przemek Radzikowski

permalink [Permalink]





International Careers & Jobs - An international employment directory, reviewing world-wide top job sites







| More

Activating ActiveX Controls

This quick tutorial demonstrates a number of techniques to activate all your APPLET, EMBED, or OBJECT ActiveX controls programmatically without requiring the user to activate each one manually. Microsoft has released information on how to activate the ActiveX control using Java Script so that the user experience is preserved.


 

 

To develop pages that allow the user to immediately use the ActiveX controls use Java Script to load controls from external script files.  Loading script elements inline with your HTML page will not solve your problem because IE will continue to handle these elements as previously - popping up the "Click to activate and use this control".

Click to activate and use this control

 

Hotfix for your browser: Download the Hotfix which will enable your browser to function as before

The following examples demonstrate a number of techniques for web developers using JavaScript to embed the controls into the browser at load time.

Using getElementsByTagName method

Below your last <object> insert the following JavaScript line which calls iefix.js:

<script type="text/javascript" src="iefix.js"></script>

// iefix.js
objects = document.getElementsByTagName("object");
for (var i = 0; i < objects.length; i++)
{
    objects[i].outerHTML = objects[i].outerHTML;
}

Using document.write to load the control

<!-- HTML File -->
<html>
  <body leftmargin=0 topmargin=0 scroll=no>
    <script src="Embed.js"></script>
  </body>
</html>

// embed.js
document.write('<embed src="examplecontrol">')

Using outerHTML to load the control

<!-- HTML File -->
<html>
  <body>
    <div>
      <script src="embedControlOuterHTML.js"></script>
    </div>
  </body>
</html>

// embedControlOuterHTML.js
embedControlLocation.outerHTML = '<embed src="examplecontrol">';

Using document.createElement to load the control

<!-- HTML File -->
<html>
  <body>
    <div id="DivID">
      <script src="createElementExplicit.js"></script>
  </body>
</html>

// createElementExplicit.js
var myObject = document.createElement('object');
DivID.appendChild(myObject);
myObject.width = "200";
myObject.height = "100";
myObject.classid= "clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6";
myObject.URL = "example.wmv";
myObject.uiMode = "none" ;

Please note:  You must initialize the attributes and add the object to the page's DOM before creating the ActiveX control to be loaded by the new element.

Using innerHTML to load the control

<!-- HTML File -->
<html>
 <head>
   <script src="external_script.js" language="JScript"></script>
 </head>
 
 <body>
   <div id="EXAMPLE_DIV_ID">
      This text will be replaced by the control
   </div>
   <script language="JScript">
     CreateControl( "EXAMPLE_DIV_ID",
                    "clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6",
                    "EXAMPLE_OBJECT_ID", "600", "400", "example.wmv",
                    "-1")
   </script>
 </body>
</html>

// external_script.js
function CreateControl(DivID, CLSID, ObjectID,
                       WIDTH, HEIGHT, URL, AUTOSTART)
{
  var d = document.getElementById(DivID);
  d.innerHTML =
    '<object classid=' + CLSID + ' id=' + ObjectID +
    ' width=' + WIDTH + ' height=' + HEIGHT +'>
    <param name="URL" value=' + URL + '>
    <param name="autoStart" value=' + AUTOSTART + '/>';
}

Automated Conversion Tool - ActiveX Patch Converter

ActiveX Patch Converter

If you can't be bothered updating your code by hand, download a handy utility which does the job for you - ActiveX Patch Converter.

Use the free converter to update your website(s) that use embedded content that were made prior to the patch that disabled direct embedding of ActiveX components within Internet Explorer. Essentially it gets rid of the need for users to click on content such as Flash before they can use them.

Portions of this code were taken from the Microsoft website.  More information about this issue can be obtained from here.

 

permalink [Permalink] - Updated: Monday, October 28, 2013





| More

 

Articles of Interest


International Careers & Jobs - An international employment directory, reviewing world-wide top job sites


 
 
(c) Capitalhead Pty Ltd
Contact Capitalhead About Us Articles & Publications Partners Solutions & Services Products Valid XHTML Valid CSS