Table of Contents | Previous | Next | Index

# Plugin

A plug-in module installed on the client.

Client-side object |
Implemented in | JavaScript 1.1

#### Created by

`Plugin` objects are predefined JavaScript objects that you access through the `navigator.plugins` array.

#### Description

A `Plugin` object is a plug-in installed on the client. A plug-in is a software module that the browser can invoke to display specialized types of embedded data within the browser. The user can obtain a list of installed plug-ins by choosing About Plug-ins from the Help menu. Each `Plugin` object is itself array containing one element for each MIME type supported by the plug-in. Each element of the array is a `MimeType` object. For example, the following code displays the `type` and `description` properties of the first `Plugin` object's first `MimeType` object.

    myPlugin=navigator.plugins[0]
    myMimeType=myPlugin[0]
    document.writeln('myMimeType.type is ',myMimeType.type,"<BR>")
    document.writeln('myMimeType.description is ',myMimeType.description)

The preceding code displays output similar to the following:

    myMimeType.type is video/quicktime
    myMimeType.description is QuickTime for Windows

The `Plugin` object lets you dynamically determine which plug-ins are installed on the client. You can write scripts to display embedded plug-in data if the appropriate plug-in is installed, or display some alternative information such as images or text if not. Plug-ins can be platform dependent and configurable, so a `Plugin` object's array of `MimeType` objects can vary from platform to platform, and from user to user. Each `Plugin` object is an element in the `plugins` array. When you use the `EMBED` tag to generate output from a plug-in application, you are not creating a `Plugin` object. Use the `document.embeds` array to refer to plug-in instances created with `EMBED` tags. See the `document.embeds` array.

#### Property Summary

Property | Description
--- | ---

    description

A description of the plug-in.

    filename

Name of the plug-in file on disk.

    length

Number of elements in the plug-in's array of `MimeType` objects.

    name

Name of the plug-in.

#### Method Summary

This object inherits the `watch` and `unwatch` methods from `Object`.

#### Examples

Example 1. The user can obtain a list of installed plug-ins by choosing About Plug-ins from the Help menu. To see the code the browser uses for this report, choose About Plug-ins from the Help menu, then choose Page Source from the View menu. Example 2. The following code assigns shorthand variables for the predefined LiveAudio properties.

    var myPluginName = navigator.plugins["LiveAudio"].name
    var myPluginFile = navigator.plugins["LiveAudio"].filename
    var myPluginDesc = navigator.plugins["LiveAudio"].description

Example 3. The following code displays the message "LiveAudio is configured for audio/wav" if the LiveAudio plug-in is installed and is enabled for the `"audio/wav"` MIME type:

    var myPlugin = navigator.plugins["LiveAudio"]
    var myType = myPlugin["audio/wav"]
    if (myType && myType.enabledPlugin == myPlugin)
       document.writeln("LiveAudio is configured for audio/wav")

Example 4. The following expression represents the number of MIME types that Shockwave can display:

    navigator.plugins["Shockwave"].length

Example 5. The following code displays the `name`, `filename`, `description`, and `length` properties for each `Plugin` object on a client:

    document.writeln("<TABLE BORDER=1><TR VALIGN=TOP>",
       "<TH ALIGN=left>i",
       "<TH ALIGN=left>name",
       "<TH ALIGN=left>filename",
       "<TH ALIGN=left>description",
       "<TH ALIGN=left># of types</TR>")
    for (i=0; i < navigator.plugins.length; i++) {
       document.writeln("<TR VALIGN=TOP><TD>",i,
          "<TD>",navigator.plugins[i].name,
          "<TD>",navigator.plugins[i].filename,
          "<TD>",navigator.plugins[i].description,
          "<TD>",navigator.plugins[i].length,
          "</TR>")
    }
    document.writeln("</TABLE>")

The preceding example displays output similar to the following:

i | name | filename | description | # of types
0 | QuickTime Plug-In | d:\nettools\netscape\nav30\Program\ plugins\NPQTW32.DLL | QuickTime Plug-In for Win32 v.1.0.0 | 1
1 | LiveAudio | d:\nettools\netscape\nav30\Program\ plugins\NPAUDIO.DLL | LiveAudio--Netscape Navigator sound playing component | 7
2 | NPAVI32 Dynamic Link Library | d:\nettools\netscape\nav30\Program\ plugins\npavi32.dll | NPAVI32, avi plugin DLL | 2
3 | Netscape Default Plugin | d:\nettools\netscape\nav30\Program\ plugins\npnul32.dll | Null Plugin | 1

#### See also

`MimeType`, `document.embeds`

## description

A human-readable description of the plug-in. The text is provided by the plug-in developers.

Property of | `Plugin`
Read-only |
Implemented in | JavaScript 1.1

## filename

The name of a plug-in file on disk.

Property of | `Plugin`
Read-only |
Implemented in | JavaScript 1.1

#### Description

The `filename` property is the plug-in program's file name and is supplied by the plug-in itself. This name may vary from platform to platform.

#### Examples

See the examples for `Plugin`.

## length

The number of elements in the plug-in's array of `MimeType` objects.

Property of | `Plugin`
Read-only |
Implemented in | JavaScript 1.1

## name

A string specifying the plug-in's name.

Property of | `Plugin`
Read-only |
Implemented in | JavaScript 1.1

#### Security

JavaScript 1.1. This property is tainted by default. For information on data tainting, see the Client-Side JavaScript Guide.

#### Description

The plug-in's name, supplied by the plug-in itself. Each plug-in should have a name that uniquely identifies it.

Table of Contents | Previous | Next | Index

Last Updated: 05/28/99 12:00:11

Copyright (c) 1999 Netscape Communications Corporation