Netscape and MSIE encapsulate plugin/embedded objects in a different way. In MSIE they are objects of the EMBED class. In Netscape Navigator they are objects commonly referred to as belonging to the Plugin class although they are really implemented as JavaObject objects. In MSIE, this is an ActiveX object.
There is additional confusion in that there is a plugins[] array that belongs to the document and another than belongs to the navigator object. They both contain collections of objects but of different types. This is further confused by the fact that the document.plugins[] array is another name for the document.embeds[] array.
Due to this confusing situation, the best recommendation is that we refer to document.embeds[] and navigator.plugins[] and quietly ignore the document.plugins[] array. Furthermore we shall refer to Plugin objects as being something the browser can use to play embedded content and Embed objects as instances of a plugin that is alive and running in a document.
Beware of confusion between document.plugins and navigator.plugins. One relates to the plugins currently used in the document while the other lists the plugins currently available and supported by the browser.
In Netscape 4.7 for Macintosh, there is a strange enumeration problem. Immediately after starting the Netscape browser, when you enumerate the properties of the netscape.plugins PluginArray object, it appears to have no properties at all. If you explicitly ask for the length property, you will get a value. During investigation, it returned the value 8 but this will depend on the number of plugins you have installed.
Now, this suggests that you should be able to access the plugins individually by index number. As soon as you access one of the plugins by its numeric index, Netscape Navigator also adds an entry using the plugin name so you can access it associatively. However, you can also enumerate the item you just created until the browser clears the array (probably when the application exits). So, although you cannot enumerate the plugins from cold, you can enumerate the ones that you have accessed by index value.
Sending a refresh message to a plugin object also allows it to be enumerable. Based on this idea, a short fragment of code is given in the example which will force the all plugins to be added to the collection as associative items which can then be enumerated.
MSIE allows the plugins to be enumerated and the length property is also enumerable. However, the plugins can only accessed by their numeric index.
To make this properly portable then, execute the bug fix code and access plugins by their numeric index and your scripts should then be reasonably portable.
// Execute this in Netscape Navigator to fix the // navigator.plugins enumeration bug for(ii=0; ii<navigator.plugins.length; ii++) { navigator.plugins[ii].refresh; }
Property | JavaScript | JScript | N | IE | Opera | NES | ECMA | DOM | CSS | HTML | Notes |
---|---|---|---|---|---|---|---|---|---|---|---|
length | 1.1 ![]() | 3.0 ![]() | 3.0 ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
Prev | Home | Next |
Plugin.refresh() | Up | PluginArray.item() |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. |