How to use the PluginDetect script

We assume here that you have a copy of PluginDetect, and that in the <head> of your webpage you have included this HTML:
       <script type="text/javascript" src="PluginDetect.js"></script>

You only need to add some javascript code to your web page to detect the plugins you are interested in.

The javascript methods available in PluginDetect are as follows:

<div id="plugindetect"></div>:  [HTML element in your web page]
   An optional <div> that you can place in your web page to assist PluginDetect (applies to Java, DevalVR, WindowsMediaPlayer, Silverlight).
   PluginDetect often inserts an <object> tag and/or <applet> tag into the web page to accomplish plugin detection. By default, these tags are inserted at the very beginning of your web page. If you do not want PluginDetect to insert any tags at the top of your page, then you may specify an alternate location. Simply create an element <div id="plugindetect"></div>, and put it somewhere within the <body>.

There are 3 restrictions on this <div>.
    i) Do NOT set the style of this <div> to display:none;
    ii) Do NOT set the style of this <div> to visibility:hidden;
    iii) When PluginDetect performs its detection, it must be able to find the <div> using
    document.getElementById("plugindetect"). Therefore the <div> must be defined/rendered
    before you actually initiate plugin detection. For example, you could have...
           <div id="plugindetect"></div>
           <script type="text/javascript">
              var version = PluginDetect.getVersion("Java", jarfile);
           </script>

PluginDetect.getVersion(pluginName):  [Returns string or null]
   Returns the version (as a string) of the installed plugin.
   Returns null when the version could not be determined (when plugin is not
      installed/enabled, or plugin is installed but the version information is unavailable).

PluginDetect.isMinVersion(pluginName, minVersion):  [Returns number]
   Returns 1 if plugin is installed (& enabled) and plugin version is >= minVersion.
   Returns 0.5 (Java only) if plugin detection has been initiated but is not yet completed. The +0.5 number only occurs for NOTF detection of the Java plugin. This result means that the plugin is installed (& enabled), but the plugin version is unknown at this point in time. The version info may or may not be available at a later time. When the plugin detection has been completed, the isMinVersion() method will return 1, 0, or -1.
   Returns 0 if plugin installed (& enabled) but version is unknown (unable to determine if version >= minVersion).
   Returns -0.2 (Java only) if plugin installed but not enabled. Some browsers occaisonally reveal enough info to make this determination.
   Returns -0.5 (Java only) if plugin detection has been initiated but is not yet completed. The -0.5 number only occurs for NOTF detection of the Java plugin. This result means that it is not known yet whether the plugin is installed or what the plugin version is. When the plugin detection has been completed, the isMinVersion() method will return 1, 0, or -1.
   Returns -1 if plugin version < minVersion, or if plugin is not installed / not enabled.
   Returns -2 if ActiveX is disabled (for Internet Explorer, this prevents plugin detection).
   Returns -3 if you supplied a bad input argument to the isMinVersion() method.

PluginDetect.onDetectionDone(pluginName, f, jarfile ):
   Even though you can use this method for any plugin, you only need to use it for Java. It will initiate plugin detection if needed, and will execute the event handler f after the plugin detection results become available. The event handler f automatically receives the PluginDetect object as an input argument [ie. f(PluginDetect){...}].
   This method is useful as sometimes Java detection results are available at unpredictable times - meaning that Java detection is not always possible "on the fly". Hence, the onDetectionDone() method will wait as long as necessary until the Java detection has completed before executing function f. You are free to use PluginDetect.getVersion() and PluginDetect.isMinVersion() inside function f to see the detection results.
   Returns 1 if plugin detection is done (OTF) and function f has been executed.
   Returns 0 if plugin detection is not done yet (NOTF) and so function f has not been executed yet.
   Returns -1 if error (plugin name input argument not specified correctly, or the method is disabled because you did not enable it when creating the script).

where pluginName = [string] plugin name such as  'Java', 'QuickTime', 'DevalVR', 'Shockwave', 'Flash',
    'WindowsMediaPlayer', 'Silverlight', or 'VLC'

and minVersion = [string or number] minimum plugin version.
   Can be a string such as  '1,5,0,0' or '1.5' or '1,5,0,1' or '1.5.0.1' etc...
   Can be a number such as 0 or 1.5 or 1.50 etc...
   If minVersion is not specified, then PluginDetect will assume minVersion is '0'.
   Strings are more versatile than numbers since '1,5,0,1' cannot be expressed as a number.

and jarfile = [string] path to the getJavaInfo.jar applet. It is strongly recommended that you use the jarfile input argument for Java detection.
   jarfile = 'getJavaInfo.jar' means the applet is in the same folder as your web page.
   jarfile = 'ABC/getJavaInfo.jar' means the applet is in a subfolder ABC.
   The path is relative to the web page itself, not relative to any external javascript file you may be using.

PluginDetect.onWindowLoaded( f ):
   Executes the event handler f after the browser window has fully loaded, and after the plugin detection results are available. The event handler f automatically receives the PluginDetect object as an input argument [ie. f(PluginDetect){...}]. You are free to use PluginDetect.getVersion() and PluginDetect.isMinVersion() inside event handler f to see the detection results.

PluginDetect.hasMimeType( mt ): [returns mimetype object from navigator array or returns null]
   The input mt is a string or an array of strings that specifies a mimetype.
   For example, let us say that mt = 'video/quicktime'. If the mimetype mt is present and enabled in the browser, then PluginDetect.hasMimeType('video/quicktime') will return the mimetype object (from the navigator array) corresponding to that mimetype. If the mimetype mt is not present or not enabled in the browser, then PluginDetect.hasMimeType('video/quicktime') will return null.
   On the other hand, let's say that mt specifies multiple mimetypes such that mt = ['video/quicktime', 'image/x-quicktime']. Then PluginDetect.hasMimeType() will return the mimetype object for either of these 2 mimetypes if either one is present and enabled. If neither mimetype is present and enabled, then PluginDetect.hasMimeType() will return null.


In addition, there are a few methods that are available only for Java:

PluginDetect.getInfo('Java', jarfile): [object]
   Returns an object with several useful properties. The properties are listed below.

PluginDetect.getInfo('Java', jarfile).OTF: [number]
   Returns 0 if Java detection has been performed on the fly (OTF).
   Returns 1 if Java detection is being performed not on the fly (NOTF) but is not completed yet.
   Returns 2 if Java detection has been performed not on the fly (NOTF) and is complete.

PluginDetect.getInfo('Java', jarfile).DeploymentToolkitPlugin: [Boolean]
   Returns true if the Deployment Toolkit browser plugin is installed and enabled.
   Returns false if Deployment Toolkit browser plugin is not installed or not enabled.

PluginDetect.getInfo('Java', jarfile).DeployTK_versions: [Array of strings]
   If the Deployment Toolkit browser plugin is installed, then this array will contain a sorted list of all Java versions that that were detected by the Deployment Toolkit plugin. The purpose of this array is to detect multiple JREs. The version strings are in the exact same format used by the Deployment Toolkit plugin (ie. "1.5.0_04", "1.6.0._03", etc...).

PluginDetect.getInfo('Java', jarfile).MimeType_versions: [Array of strings]
   Suppose your browser has one or more mimetypes of the format "application/x-java-applet;jpi-version=A.B.C_DE". Then this array will contain a sorted list of installed Java versions based on these given mimetypes. The purpose of this array is to detect multiple JREs. The version strings are in the exact same format as those in the mimetypes array (ie. "1.5.0_04", "1.6.0._03", etc...).

PluginDetect.getInfo('Java', jarfile).All_versions: [Array of strings]
   This array contains a sorted list of all detected Java versions from all possible sources (including DeployTK_versions array, MimeType_versions array, and others).

PluginDetect.getInfo('Java', jarfile).vendor: [string]
   The Java vendor. Possible value are Sun Microsystems, Apple Inc, Microsoft Corp., etc...

PluginDetect.getInfo('Java', jarfile).AppletHTML: [string]
   If the jarfile is used to detect Java, then AppletHTML will show the HTML used to instaniate the applet. When AppletHTML is an "" empty string, then some other method was used to detect Java.

PluginDetect.getInfo('Java', jarfile).name: [string]
   The plugin name as given in the navigator.plugins array.

PluginDetect.getInfo('Java', jarfile).description: [string]
   The plugin description as given in the navigator.plugins array.



There are also a few other properties of PluginDetect that you may find useful:

PluginDetect.isIE:  [boolean]
   Returns true if the browser is Internet Explorer.
   Returns false if the browser is not Internet Explorer.

PluginDetect.IEver:  [number]
   Returns version of Internet Explorer.

PluginDetect.ActiveXEnabled:  [boolean]
   Returns true if browser is Internet Explorer and ActiveX is enabled in the browser settings (ActiveX must be enabled for PluginDetect to work).

PluginDetect.isGecko: [Boolean]
   Returns true if the browser is Gecko based (ie. Firefox, Mozilla, Netscape, Flock, SeaMonkey, K-Meleon, etc...).
   Returns false if the browser is not Gecko based.

PluginDetect.GeckoRV: [null or string]
   Returns a string if the browser is Gecko based. The string contains the CVS branch tag of the source code used to create the version of Gecko in your browser. The branch tag is contained in navigator.userAgent and follows the string 'rv:'.
   Returns null if the browser is not Gecko based.




PluginDetect is Unobtrusive

The PluginDetect script has been made as unobtrusive as possible so as to not interfere with any other scripts you are using. It uses only 1 name in the global namespace: PluginDetect (an object). Any other variable names that you see in the PluginDetect script are local variables only, and will not affect the global namespace or any other scripts.

Some people have noticed that I use the '$' variable name in PluginDetect, and have wrongly assumed that this means that PluginDetect will interfere with the Prototype script (which defines a $() method). Again, the '$' variable in PluginDetect is a local variable only, and will not interfere with the global $() method of Prototype.


Top of Page