最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Difference between embedding ActiveX object with <object> tag or creating one with new ActiveXObject(

programmeradmin4浏览0评论

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 badges
Add a ment  | 

1 Answer 1

Reset to default 5

The 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).

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论