I want to embed both an ActiveX and NPAPI plugins in one page using nested object tags (as recommended by Mozilla) instead of relying on user agent.
The problem is: I want to use one object id, such as id="MyObject", which will be defined in both object tags (for the ActiveX or NPAPI) so that my Javascript calls the object MyObject directly regardless of whether it is an ActiveX or NPAPI.
I hope I made myself clear.
getElementsByClassName didn't work for me, so I did a simple trick that worked beautifully.
<object classid="clsid:something" id="obj1" >
<object type="application/x-blah-blah-blah" id="obj2">
</object></object>
Then in my JavaScript code I called at the beginning:
if (obj2!=null && obj2!=undefined)
or if you wish if (!(obj2==null || obj2==undefined))
whatever you like
obj1 = getElementById("obj2");
That will create the object for the NPAPI plugin, or if the browser is IE, will proceed smoothly without entering that if statement (IE doesn't allow you to use getElementById to assign to an object that has an id attribute). Then you just use obj1 for your processing or use it to instantiate another object as you see fit.