views:

503

answers:

2

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* );
A: 

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
Haven't Microsoft fixed the "Global JS objects for every element with an ID" bug yet?
David Dorward
Your answer doesn't address the question at all BTW.
David Dorward
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
A: 

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