JavaScript: Detect Plug-ins and MIME Types

Plug-ins are programs that add the ability to play audio, video, animation etc. Some examples of plugins are the Adobe Flash Player, QuickTime etc. MIME Types are used to exchange file types across the Internet, such as image, audio, video etc.

You can use JavaScript to detect plugins and MIME Types.

You can detect plugins in JavaScript by looping the plugins[] array of the navigator object and accessing the properties of the plugin object. Similarly MIME Types are support by helper applications or by plug-ins.

Note: The MIME Type of plugins vary according to each platform. The MIME types array and plugins array is empty in IE. IE support ActiveX objects.

Let us see some code:

JavaScript Plugin Detection

In the code shown above, we are detecting the installed plug-ins and the MIME types that it handles.

OUTPUT

JavaScript Plugin Detection

In order to check for a particular plugin, like the Shockwave plugin, use the following code:

if (navigator.plugins["Shockwave"]){}




About The Author

Suprotim Agarwal
Suprotim Agarwal, Developer Technologies MVP (Microsoft Most Valuable Professional) is the founder and contributor for DevCurry, DotNetCurry and SQLServerCurry. He is the Chief Editor of a Developer Magazine called DNC Magazine. He has also authored two Books - 51 Recipes using jQuery with ASP.NET Controls. and The Absolutely Awesome jQuery CookBook.

Follow him on twitter @suprotimagarwal.

No comments: