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: Javascript
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
Leave a reply