A plug-in is a piece of software or module which acts as add-on or extension to a web browser and adds additional functionality to existing software application. There are programs which can be installed easily and used as part of the web browser. It allows web browser to display additional content and enables customization when an application supports plug-ins.
The examples for plug-ins are Flash player, QuickTime Player, Acrobat Reader, Shockwave player, Java, Windows Media Player etc. Most plug-ins are available as free downloads. To install plug-ins, we visit the plug-ins developer site and click on the link which will download installer for the plug-in which we have selected. The plug-ins usually used to support adding new features, to reduce size of the application etc.
Now let us see an example below which demonstrates a way to detect installed plugins on different browsers:
<!DOCTYPE html> <head> <TITLE>Example to detect Installed Plugins</TITLE> </head> <body> <script language="javascript"> //get the total number of installed plugins numPlugins = navigator.plugins.length; if (numPlugins > 0) document.writeln("Installed plug-ins"); else document.writeln("No plug-ins are installed."); //If plugins installed, create a table with headers- Mime Type, Description, Suffixes, Enabled for (i = 0; i < numPlugins; i++) { plugin = navigator.plugins[i]; document.write("<center><font size=+1><b>"); document.write(plugin.name); document.writeln("</b></font></center><br>"); document.writeln("<dl>"); document.writeln("<dd>File name:"); document.write(plugin.filename); document.write("<dd><br>"); document.write(plugin.description); document.writeln("</dl>"); document.writeln("<p>"); document.writeln("<table border=1 >"); document.writeln("<tr>"); document.writeln("<th width=20%>Mime Type</th>"); document.writeln("<th width=50%>Description</th>"); document.writeln("<th width=20%>Suffixes</th>"); document.writeln("<th>Enabled</th>"); document.writeln("</tr>"); numTypes = plugin.length; //This section of code displays the actual values for each of the columns (Mime Type, Description, Suffixes, Enabled) for (j = 0; j < numTypes; j++) { mimetype = plugin[j]; if (mimetype){ enabled = "No"; enabledPlugin = mimetype.enabledPlugin; if (enabledPlugin && (enabledPlugin.name == plugin.name)) enabled = "Yes"; document.writeln("<tr align=center>"); document.writeln("<td>"); document.write(mimetype.type); document.writeln("</td>"); document.writeln("<td>"); document.write(mimetype.description); document.writeln("</td>"); document.writeln("<td>"); document.write(mimetype.suffixes); document.writeln("</td>"); document.writeln("<td>"); document.writeln(enabled); document.writeln("</td>"); document.writeln("</tr>"); } } document.write("</table>"); } </script> </body> </html>
JavaScript Plug-In Support Demo
- Save the file as pluginexample.html in your system.
- Just open the file in the browser, you will see the below picture in the browser.
When the execution process is completed successfully we will get the following output, displaying all the installed plugins:
You can execute this code for different browsers installed on your system. If you have any questions, please write it in the comments section.