Detecting Plug-ins

The following code use the the plugins array to determine the plugins.

Each item in the plugins array contains:

NameMeaning
nameThe name of the plug-in
descriptionThe description of the plug-in
filenameThe filename for the plug-in
lengthThe number of MIME types handled by this plug-in
 
<!DOCTYPE HTML> 
<html> 
    <head> 
        <title>Example</title> 
    </head> 
    <body> 
        <script> 
            function hasPlugin(name){
                name = name.toLowerCase();
                for (var i=0; i < navigator.plugins.length; i++){
                    if (navigator.plugins[i].name.toLowerCase().indexOf(name) > -1){
                        return true;
                    }
                }
                return false;
            }
            function hasIEPlugin(name){ 
                try { 
                    new ActiveXObject(name); 
                    return true; 
                } catch (ex){ 
                    return false; 
                } 
            } 
            document.writeln(hasPlugin("Flash"));
            document.writeln(hasIEPlugin("ShockwaveFlash.ShockwaveFlash")); 

        </script> 
    </body> 
</html>
  
Click to view the demo
Home 
  JavaScript Book 
    DOM  

Navigator:
  1. The Navigator Object
  2. Detecting Plug-ins
  3. plugin's MimeType