I've noticed that there are 2 ways we can create ActiveX object in JavaScript, one is by embedding:
<object id="TestControl" classid="clsid:xxx-xx-xx-xx"></object>
and then later on obtain object using DOM:
var myControl = document.getElementById('TestControl');
Another way is to create instance of ActiveXObject:
var myControl2 = new ActiveXObject('Test.TestControl');
What exactly is different from ActiveX object perspective? Is one approach better then the other? Are there any differences in performance?
Thanks.
I've noticed that there are 2 ways we can create ActiveX object in JavaScript, one is by embedding:
<object id="TestControl" classid="clsid:xxx-xx-xx-xx"></object>
and then later on obtain object using DOM:
var myControl = document.getElementById('TestControl');
Another way is to create instance of ActiveXObject:
var myControl2 = new ActiveXObject('Test.TestControl');
What exactly is different from ActiveX object perspective? Is one approach better then the other? Are there any differences in performance?
Thanks.
Share asked Dec 15, 2012 at 0:10 DreamerNSDreamerNS 912 silver badges4 bronze badges1 Answer
Reset to default 5The two are pretty much equivalent.
The <object>
notation is official HTML; var myControl2 = new ActiveXObject('Test.TestControl');
can only be used in a scripting language like JScript or ASP; it isn't available for HTML directly.
Also: the "object" notation takes a class ID: all you need is the ActiveX object installed on your system (or installable over the Internet). The Javascript example you gave has a PROGID ... which requires 1) the ActiveX object already be installed, and 2) the ActiveX object must have a PROGID (which is optional, not required, by ActiveX).