The object returned is a sub-class of the Array object. It is a PluginArray.
Here is a list of some plugins displayed by using a JavaScript to unwrap the plugins array:
Headspace Beatnik Helper Stub Plugin V1.0.1
LiveAudio
Shockwave for Director
PDFViewer
QuickTime Plug-in 4.1
RealPlayer(tm) G2 LiveConnect-Enabled Plug-in (Mac)
Shockwave Flash
The default plugin has been omitted since it is always there. However note that it is not always spelled the same in all browsers. If you are displaying a list of plugins to the user, then be careful how you eliminate unwanted items.
You may check for the existence of a plugin using the following logical expression:
(navigator.plugins["TheRequiredItem"] != null)
However, this may not always work due to the naming conventions.
The example enumerates some plugins and of course the output depends on the plugins you have installed. You might typically see something like this listed:
Headspace Beatnik Helper Stub Plugin V1.0.1
Default Plug-in
LiveAudio
Shockwave for Director
PDFViewer
QuickTime Plug-in 4.1
RealPlayer(tm) G2 LiveConnect-Enabled Plug-in (Mac)
Shockwave Flash
This sometimes yields the undefined value and therefore it is impossible to determine which plugins are supported in MSIE version 4.5 for Macintosh and other browser/platform combinations that do not support the plugins array.
If this is supported in a target browser you are writing scripts for, the exact results will depend on the user's configuration. There is enormous scope for users to install a variety of free and downloadable plugins from the web. There is no guarantee as to what plugins they will have installed. Their browser may only report a couple of plugins (theoretically the minimum is just the one default plugin) or they may have many plugins installed.
The associative array technique may not always work across browsers.
Netscape and MSIE encapsulate plugin/embedded objects in different ways. In MSIE they are objects of the EMBED class. In Netscape 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.
To help clarify 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 will be an instance of a plugin that is alive and running in a document.
<!-- Display all plugin names --> <HTML> <HEAD> </HEAD> <BODY> <SCRIPT> for (var myIndex=0; myIndex<navigator.plugins.length; myIndex++) { document.write(navigator.plugins[myIndex].name); document.write("<HR>"); } </SCRIPT> </BODY> </HTML>
See also: | Plugin object, PluginArray object |
Prev | Home | Next |
Navigator.plugins.refresh() | Up | Navigator.preference() |
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. |