NavigatorPlugins.plugins

  • Revision slug: Web/API/NavigatorPlugins.plugins
  • Revision title: navigator.plugins
  • Revision id: 482177
  • Created:
  • Creator: Benjamin Smedberg
  • Is current revision? No
  • Comment

Revision Content

{{DomRef}}

Summary

Returns a {{domxref("PluginArray")}} object, listing the plugins installed in the application.

Note: Applications which are checking for the presence of a browser plugin should use navigator.mimeTypes instead of navigator.plugins.

Syntax

plugins = navigator.plugins;

plugins is used to access {{domxref("Plugin")}} objects either by name or as an array of items.

The returned value is not a JavaScript array, but has the length property and supports accessing individual items using bracket notation (plugins{{mediawiki.external(2)}}), as well as via item(index) and namedItem("name") methods.

Enumeration of navigator.plugins may be removed as a privacy measure in a future version of Firefox.

Example

The following example checks for the Flash version:

{{gecko_minversion_note("1.9.2", "The version property was added in Gecko 1.9.2.")}}

function getFlashVersion()
{
  var flash = navigator.plugins['Shockwave Flash'];
  if (flash === undefined) {
    // flash is not present
    return undefined;
  }
  return flash.version;
}

The following example prints out information about the installed plugin(s) for the high-level document. Note the properties available on the Plugin object: name, filename, description, and version.

var L = navigator.plugins.length;

document.write(
  L.toString() + " Plugin(s)<br>" +
  "Name | Filename | description<br>"
);

for(var i = 0; i < L; i++) {
  document.write(
    navigator.plugins[i].name +
    " | " +
    navigator.plugins[i].filename +
    " | " +
    navigator.plugins[i].description +
    " | " +
    navigator.plugins[i].version +
    "<br>"
  );
}

Notes

The {{domxref("Plugin")}} object exposes a small interface for getting information about the various plugins installed in your browser. A list of plugins is also available by entering about:plugins in the browser's Location bar.

Specification

{{DOM0}}

Revision Source

<div>
  {{DomRef}}</div>
<h2 id="Summary" name="Summary">Summary</h2>
<p>Returns a {{domxref("PluginArray")}} object, listing the plugins installed in the application.</p>
<div class="note">
  <p><strong>Note: </strong>Applications which are checking for the presence of a browser plugin should use <a href="/en-US/docs/Web/API/NavigatorPlugins.mimeTypes">navigator.mimeTypes</a> instead of navigator.plugins.</p>
</div>
<h2 id="Syntax" name="Syntax">Syntax</h2>
<pre class="syntaxbox">
<var>plugins</var> = navigator.plugins;
</pre>
<p><code>plugins</code> is used to access {{domxref("Plugin")}} objects either by name or as an array of items.</p>
<p>The returned value is not a JavaScript array, but has the <code>length</code> property and supports accessing individual items using bracket notation (<code>plugins{{mediawiki.external(2)}}</code>), as well as via <code>item(<var>index</var>)</code> and <code>namedItem(<em>"name"</em>)</code> methods.</p>
<div class="warning">
  <p>Enumeration of navigator.plugins may be removed as a privacy measure in a future version of Firefox.</p>
</div>
<h2 id="Example" name="Example">Example</h2>
<p>The following example checks for the Flash version:</p>
<p>{{gecko_minversion_note("1.9.2", "The <code>version</code> property was added in Gecko 1.9.2.")}}</p>
<pre>
function getFlashVersion()
{
  var flash = navigator.plugins['Shockwave Flash'];
  if (flash === undefined) {
    // flash is not present
    return undefined;
  }
  return flash.version;
}
</pre>
<p>The following example prints out information about the installed plugin(s) for the high-level document. Note the properties available on the Plugin object: <code>name</code>, <code>filename</code>, <code>description</code>, and <code>version</code>.</p>
<pre class="brush:js">
var L = navigator.plugins.length;

document.write(
  L.toString() + " Plugin(s)&lt;br&gt;" +
  "Name | Filename | description&lt;br&gt;"
);

for(var i = 0; i &lt; L; i++) {
  document.write(
    navigator.plugins[i].name +
    " | " +
    navigator.plugins[i].filename +
    " | " +
    navigator.plugins[i].description +
    " | " +
    navigator.plugins[i].version +
    "&lt;br&gt;"
  );
}</pre>
<h2 id="Notes" name="Notes">Notes</h2>
<p>The {{domxref("Plugin")}} object exposes a small interface for getting information about the various plugins installed in your browser. A list of plugins is also available by entering <code>about:plugins</code> in the browser's Location bar.</p>
<h2 id="Specification" name="Specification">Specification</h2>
<p>{{DOM0}}</p>
Revert to this revision