views:

402

answers:

2

I am trying to get some javascript to talk to an activex control. When this works and the JS can get the controls status I get a certain message. If not I get an error message.

In IE7/8 you are prompted to accept the activex control (via the warning bar thing), but in IE6 the js just cant get the controls status.

I have also tries creating the control using document.write from an external file so that it can run as soon as the page loads. The control is invisible so I can't tell just from looking at the page if it's being loaded at all.

I'd appreciate your help.

+1  A: 

It is likely the ActiveX control activation mechanism that started in IE7, but I thought was supposed to be removed in a service pack later on. It is a major pain for control developers and web page authors.

This article gives some background and advice: http://msdn.microsoft.com/en-us/library/ms537508.aspx

There is also some useful information here: http://blogs.msdn.com/ie/archive/2007/11/08/ie-automatic-component-activation-changes-to-ie-activex-update.aspx

JohnFx
I marked this as the correct answer because this is all true and does trip people up, but as it turns out microsoft added a killbit for the activex control I was using in a security update, and this was stopping the control running.
A: 

to activate a control in IE after the automatic mechinism (or before) was disabled due to the lawsuit place a script tag in the HTML as follows

<script src="control.js"></script>

then create a control.js file in the root of the website like this: (you'll of course have to edit the script for the classid of your control and it's parms - but you get the idea)

document.write('<OBJECT align=left classid="CLSID:8BD21D30-EC42-11CE-9E0D-00AA006002F3" id=Customer style="HEIGHT: 23px; text-align:left; LEFT: 0px; TOP: 100px; WIDTH: 160px" tabIndex=4 width=75 onchange="NewCustomer" VIEWASTEXT>');
document.write('<param name="VariousPropertyBits" value="746604571">');
document.write('<param name="BackColor" value="2147483653">');
document.write('<param name="ForeColor" value="2147483656">');
document.write('<param name="MaxLength" value="0">');
document.write('<param name="BorderStyle" value="0">');
document.write('<param name="ScrollBars" value="0">');
document.write('<param name="DisplayStyle" value="3">');
document.write('<param name="MousePointer" value="0">');
document.write('<param name="Size" value="4233;609">');
document.write('<param name="PasswordChar" value="0">');
document.write('<param name="ListWidth" value="0">');
document.write('<param name="BoundColumn" value="1">');
document.write('<param name="TextColumn" value="65535">');
document.write('<param name="ColumnCount" value="1">');
document.write('<param name="ListRows" value="8">');
document.write('<param name="cColumnInfo" value="0">');
document.write('<param name="MatchEntry" value="1">');
document.write('<param name="ListStyle" value="0">');
document.write('<param name="ShowDropButtonWhen" value="2">');
document.write('<param name="ShowListWhen" value="1">');
document.write('<param name="DropButtonStyle" value="1">');
document.write('<param name="MultiSelect" value="0">');
document.write('<param name="Value" value>');
document.write('<param name="Caption" value>');
document.write('<param name="PicturePosition" value="458753">');
document.write('<param name="BorderColor" value="2147483654">');
document.write('<param name="SpecialEffect" value="2">');
document.write('<param name="Accelerator" value="0">');
document.write('<param name="GroupName" value>');
document.write('<param name="FontName" value="Arial">');
document.write('<param name="FontEffects" value="1073741824">');
document.write('<param name="FontHeight" value="165">');
document.write('<param name="FontOffset" value="0">');
document.write('<param name="FontCharSet" value="0">');
document.write('<param name="FontPitchAndFamily" value="2">');
document.write('<param name="ParagraphAlign" value="1">');
document.write('<param name="FontWeight" value="400">');
document.write('<param name="autoStart" value="-1"></object>');

autoStart=-1 being the import one for getting it running automatically (once installed). You probably want to add a CODEPATH tpo the object that points to a control.CAB file for installation too. (I didn't need this in my case)

Booji Boy