Javascript – How to detect if an ActiveX control is loaded

activexjavascript

I would like to integrate the Aurigma image uploader (http://www.aurigma.com/Products/ImageUploader/) on a website.

On Internet Explorer the control is an ActiveX control which issues a security prompt prior to the first installation.

To give the user instructions about how to react to this security warning I'd like to display an information window. I want to display this window only the control is not loaded.

  if (controlIsNotLoaded()) {
    doSomething()
  }

How can I do that?

Best Solution

Assuming you have the id of the object tag (if it is coming from that) then test for the object attribute of the element against null.

function controlNotLoaded()
{
     var obj = document.getElementById("controlId");
     return (obj.object == null);
}

If you are using new ActiveXObject then it will throw an exception. Of course this will only tell you if the control isn't able to be created, not necessarily why.