Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
How to list down all the plug-in installed in your browser?
To list down all the plug-ins installed in the web browser, use the JavaScript navigator object. The JavaScript navigator object includes a child object called plugins. This object is an array, with one entry for each plug-in installed on the browser.
Understanding navigator.plugins
The navigator.plugins property returns a PluginArray object containing Plugin objects representing the plugins installed in the browser. Each plugin object has properties like name, filename, and description.
Example
You can try to run the following code to list down all the plug-ins installed in your browser:
<html>
<head>
<title>List of Plug-Ins</title>
</head>
<body>
<table border="1">
<tr>
<th>Plug-in Name</th>
<th>Filename</th>
<th>Description</th>
</tr>
<script>
for (i = 0; i < navigator.plugins.length; i++) {
document.write("<tr><td>");
document.write(navigator.plugins[i].name);
document.write("</td><td>");
document.write(navigator.plugins[i].filename);
document.write("</td><td>");
document.write(navigator.plugins[i].description);
document.write("</td></tr>");
}
</script>
</table>
</body>
</html>
Modern Approach Using DOM Manipulation
Instead of using document.write(), here's a more modern approach that creates the table dynamically:
<html>
<head>
<title>List of Plug-Ins</title>
</head>
<body>
<h2>Browser Plugins</h2>
<div id="pluginList"></div>
<script>
function listPlugins() {
let output = '<table border="1">';
output += '<tr><th>Plugin Name</th><th>Filename</th><th>Description</th></tr>';
for (let i = 0; i < navigator.plugins.length; i++) {
output += '<tr>';
output += '<td>' + navigator.plugins[i].name + '</td>';
output += '<td>' + navigator.plugins[i].filename + '</td>';
output += '<td>' + navigator.plugins[i].description + '</td>';
output += '</tr>';
}
output += '</table>';
document.getElementById('pluginList').innerHTML = output;
}
// Call function when page loads
listPlugins();
</script>
</body>
</html>
Checking for Plugin Support
You can also check if a specific plugin is available before using it:
<script>
function checkPlugin(pluginName) {
for (let i = 0; i < navigator.plugins.length; i++) {
if (navigator.plugins[i].name.indexOf(pluginName) !== -1) {
console.log(pluginName + " is installed");
return true;
}
}
console.log(pluginName + " is not installed");
return false;
}
// Example usage
checkPlugin("Flash");
checkPlugin("PDF");
</script>
Browser Compatibility Note
The navigator.plugins property is supported in all major browsers, but some modern browsers may return an empty array for security reasons. In Chrome and Edge, plugins like Flash are being phased out, so you might see fewer plugins listed.
Conclusion
The navigator.plugins object provides a straightforward way to list browser plugins. While document.write() works, using DOM manipulation offers better control and modern coding practices.
