4/18/2006 8:36:05 AM

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 -->
  <body leftmargin=0 topmargin=0 scroll=no>
    <script src="Embed.js"></script>

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

Using outerHTML to load the control

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

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

Using document.createElement to load the control

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

// createElementExplicit.js
var myObject = document.createElement('object');
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 -->
   <script src="external_script.js" language="JScript"></script>
   <div id="EXAMPLE_DIV_ID">
      This text will be replaced by the control
   <script language="JScript">
     CreateControl( "EXAMPLE_DIV_ID",
                    "EXAMPLE_OBJECT_ID", "600", "400", "example.wmv",

// 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