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"]){}

Will you give this article a +1 ? Thanks in advance


About The Author

Suprotim Agarwal
Suprotim Agarwal, ASP.NET Architecture MVP (Microsoft Most Valuable Professional) works as an Architect Consultant and provides consultancy on how to design and develop Web applications.

Suprotim is also the founder and primary contributor to DevCurry, DotNetCurry and SQLServerCurry. He is the Editor of a Developer Magazine called DNC Magazine. He has also written two EBooks 51 Recipes using jQuery with ASP.NET Controls. and The Absolutely Awesome jQuery CookBook

Follow him on twitter @suprotimagarwal

No comments: