Section 25.227. Plugin: describes an installed plug-in


25.227. Plugin: describes an installed plug-in

JavaScript 1.1; not supported by IE: Object Plugin

25.227.1. Synopsis

 navigator.plugins[i] navigator.plugins['name'] 

25.227.2. Properties


description

A read-only string that contains a human-readable description of the specified plug-in. The text of this description is provided by the creators of the plug-in and may contain vendor and version information as well as a brief description of the plug-in's function.


filename

A read-only string that specifies the name of the file on disk that contains the plug-in program itself. This name may vary from platform to platform. The name property is more useful than filename for identifying a plug-in.


length

Each Plugin object is also an array of MimeType objects that specify the data formats supported by the plug-in. As with all arrays, the length property specifies the number of elements in the array.


name

The name property of a Plugin object is a read-only string that specifies the name of the plug-in. Each plug-in should have a name that uniquely identifies it. The name of a plug-in can be used as an index into the navigator.plugins[] array. You can use this fact to determine easily whether a particular named plug-in is installed in the current browser:

 var flash_installed = (navigator.plugins["Shockwave Flash"] != null); 

25.227.3. Array Elements

The array elements of the Plugin object are MimeType objects that specify the data formats supported by the plug-in. The length property specifies the number of MimeType objects in this array.

25.227.4. Description

A plug-in is a software module that can be invoked by a browser to display specialized types of embedded data within the browser window. Plug-ins are represented by the Plugin object, and the plugins[] property of the Navigator object is an array of Plugin objects representing the installed plug-ins for the browser. IE does not support the Plugin object, and the navigator.plugins[] array is always empty on that browser.

navigator.plugins[] may be indexed numerically when you want to loop through the complete list of installed plug-ins, looking for one that meets your needs (for example, one that supports the MIME type of the data you want to embed in your web page). This array can also be indexed by plug-in name, however. That is, if you want to check whether a specific plug-in is installed in the user's browser, you might use code like this:

 var flash_installed = (navigator.plugins["Shockwave Flash"] != null); 

The name used as an array index with this technique is the same name that appears as the value of the name property of the Plugin.

The Plugin object is somewhat unusual in that it has both regular object properties and array elements. The properties of the Plugin object provide various pieces of information about the plug-in, and its array elements are MimeType objects that specify the embedded data formats that the plug-in supports. Don't confuse the fact that Plugin objects are stored in an array of the Navigator object with the fact that each Plugin object is itself an array of MimeType objects. Because there are two arrays involved, you may end up with code that looks like this:

 navigator.plugins[i][j]            // The jth MIME type of the ith plug-in navigator.plugins["LiveAudio"][0]  // First MIME type of LiveAudio plug-in 

Finally, note that while the array elements of a Plugin object specify the MIME types supported by that plug-in, you can also determine which plug-in supports a given MIME type with the enabledPlugin property of the MimeType object.

25.227.5. See Also

Navigator, MimeType




JavaScript. The Definitive Guide
JavaScript: The Definitive Guide
ISBN: 0596101996
EAN: 2147483647
Year: 2004
Pages: 767

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net