30
Sep

To check if flash plugin is installed

   Posted by: Pradeep   in Scripting

Here is the code that will help us to determine if flash is installed on the browser. To know if flash is installed in IE, we need to get around it using VB Script. The reason:

IE does not populate the available plugins in navigator.plugins array. The plugin array is always empty irrespective of installed plugins. The only way we can check if the plugin is installed in IE is by using the createObject method available in VBScript.


<script language="javascript">
<!--

var flashinstalled = 0;
var flashversion = 0;
MSDetect = "false";
if (navigator.plugins && navigator.plugins.length)
{
x = navigator.plugins["Shockwave Flash"];
if (x)
{
 flashinstalled = 2;
 if (x.description)
 {
  y = x.description;
  flashversion = y.substring(y.indexOf('.'),15);
 }
}
else
 flashinstalled = 1;
if (navigator.plugins["Shockwave Flash 2.0"])
{
 flashinstalled = 2;
 flashversion = 2;
}
}
else if (navigator.mimeTypes && navigator.mimeTypes.length)
{
x = navigator.mimeTypes['application/x-shockwave-flash'];
if (x && x.enabledPlugin)
 flashinstalled = 2;
else
 flashinstalled = 1;
}
else
MSDetect = "true";

-->
</script>

<script language="vbscript">
<!--
on error resume next

If MSDetect = "true" Then
For i = 2 to 10
 If Not(IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & i))) Then

 Else
  flashinstalled = 2
  flashversion = i
 End If
Next
End If

If flashinstalled = 0 Then
flashinstalled = 1
End If
-->
</script>

<script language="javascript">
<!--
if(flashinstalled==2)
{
alert("Flash version " + flashversion + " is installed");
}
else
{
alert("Flash is not installed");
}
-->
</script>

Tags:

This entry was posted on Tuesday, September 30th, 2008 at 8:34 am and is filed under Scripting. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

2 comments so far

Marco
 1 

`flashversion = y.charAt(y.indexOf(’.')-1);’ retuns 1 on Flash 10.0. Any sugestion to get 10?

November 2nd, 2008 at 6:16 pm
 2 

Please try this way:

flashversion = y.substring(y.indexOf(’.'),15);

November 11th, 2008 at 4:39 pm

Leave a reply

Name (*)
Mail (will not be published) (*)
URI
Comment