3

I have the following declaration in my code:

<object id="myObject" name="myObject" 
    data="data:application/x-oleobject;base64,ab9qcMENN0WE41oij7hs8764yu+YEwAA2BMABB=="
    classid="clsid:83A04F76-85DF-4f36-A94E-BA3465007CDA" viewastext
    codebase="someAssembly.dll#version=UNKNOWN">
</object>

I want to create an instance of this same object, but inside a .js file, and so I'd like to construct this object without needing to use an tag (if this is even possible):

var myObject = new ActiveXObject( *Something goes here* );
ThinkingStiff
  • 64,767
  • 30
  • 146
  • 239
Justin
  • 84,773
  • 49
  • 224
  • 367

2 Answers2

2

This is the way to create a new instance:

var newObj = new ActiveXObject(servername.typename[, location]);

As you can see there's an optional parameter location that you can use to access remote ActiveX objects but read details about it here: MSDN ActiveXObject (you'll find some info at the end of the document).

Robert Koritnik
  • 103,639
  • 52
  • 277
  • 404
-2

You can access the "OBJECT" simply by calling it by its id. For instance:

<object id="myObject" name="myObject" 
    data="data:application/x-oleobject;base64,ab9qcMENN0WE41oij7hs8764yu+YEwAA2BMABB=="
    classid="clsid:83A04F76-85DF-4f36-A94E-BA3465007CDA" viewastext
    codebase="someAssembly.dll#version=UNKNOWN">
</object>

Now, I can access it as follows:

myObject.userText = "hello!";

Where "userText" is a property of that object.

I hope this would answer your question.

Ramiz Uddin
  • 4,249
  • 4
  • 40
  • 72
  • Haven't Microsoft fixed the "Global JS objects for every element with an ID" bug yet? – Quentin Jul 15 '09 at 11:21
  • 3
    Your answer doesn't address the question at all BTW. – Quentin Jul 15 '09 at 11:22
  • I'm afraid they do. I recently implement an activeX control which is a component instead of a control and I did the same calling by the OBEJCT id attribute value. And it works for me. – Ramiz Uddin Jul 15 '09 at 11:39