0

Is there any possibility to check if the user has activated shockwave flash plug-in? How to do this in javascript?

I hope somebody can help me.

Ronald
  • 2,721
  • 8
  • 33
  • 44
  • possible duplicate of [Cross Browser Flash Detection in Javascript](http://stackoverflow.com/questions/159261/cross-browser-flash-detection-in-javascript) – VirtualTroll Mar 25 '14 at 10:37

2 Answers2

1

Check this:

<script type="text/javascript">
<!--
var MM_contentVersion = 9;
var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
if ( plugin ) {
        var words = navigator.plugins["Shockwave Flash"].description.split(" ");
        for (var i = 0; i < words.length; ++i)
        {
        if (isNaN(parseInt(words[i])))
        continue;
        var MM_PluginVersion = words[i];
        }
    var MM_FlashCanPlay = MM_PluginVersion >= MM_contentVersion;
}
else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0
   && (navigator.appVersion.indexOf("Win") != -1)) {
    document.write('<SCR' + 'IPT LANGUAGE=VBScript> n'); //FS hide this from IE4.5 Mac by splitting the tag
    document.write('on error resume next n');
    document.write('MM_FlashCanPlay = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & MM_contentVersion)))n');
    document.write('</SCR' + 'IPT> n');
}
if ( MM_FlashCanPlay ) {
    document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="160" height="120">');
    document.write('<param name="movie" value="animation.swf">');
    document.write ('<param name="quality" value="high">');
    document.write ('<param name="wmode" value="transparent">');
    document.write('<embed src="animation.swf" width="160" height="120" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" wmode="transparent"></embed></object>');
} else{
    document.write('<a href="./"><img src="replaced-image.png" alt="Flash Plugin not Installed" border="0"></a>');

}
//-->

</script>
Yetispapa
  • 2,174
  • 2
  • 30
  • 52
1
function detectflash(){
    if (navigator.plugins != null && navigator.plugins.length > 0){
        return navigator.plugins["Shockwave Flash"] && true;
    }
    if(~navigator.userAgent.toLowerCase().indexOf("webtv")){
        return true;
    }
    if(~navigator.appVersion.indexOf("MSIE") && !~navigator.userAgent.indexOf("Opera")){
        try{
            return new ActiveXObject("ShockwaveFlash.ShockwaveFlash") && true;
        } catch(e){}
    }
    return false;
}

To use it :

if(detectflash()){
    alert("Flash is enabled");
} else{
alert("Flash is not available");
}
radia
  • 1,456
  • 1
  • 13
  • 18