I have to check if a specific version of flash player 10.2.161.23 is installed on the client's machine or not from my javascript code. Client's system has many other versions with same "Major version" like 10.1.102.64 etc.. I tried the following code snippet

for(var i = 10; i > 0; i--)  
        {    
            try
            {     
                flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+String(i));    
            }
            catch(e)
            {
              alert("in ctach");
            }

             version = flash.GetVariable("$version");  
                 alert(version);

        }

Client has 10.1.102.64 & 10.2.161.23 on his system and my above code is recognizing only, 10.1.102.64 but not recognizing the other version with the same "Major version no:".

Can I use new ActiveXObject("MacromediaFlashPaper.MacromediaFlashPaper"); instead of Shockwaveflash.shockwaveflash. Does this have any impact? The flash player version I want to detect is a 64 bit version.

Can anyone kindly let me know the reason and fix for this please. Thanks In advance.

2

There are 2 best solutions below

0
On BEST ANSWER

Try following script

function getFlashVersion(){
  // ie
  try {
    try {
      // avoid fp6 minor version lookup issues
      // see: http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/
      var axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6');
      try { axo.AllowScriptAccess = 'always'; }
      catch(e) { return '6,0,0'; }
    } catch(e) {}
    return new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version').replace(/\D+/g, ',').match(/^,?(.+),?$/)[1];
  // other browsers
  } catch(e) {
    try {
      if(navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin){
        return (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]).description.replace(/\D+/g, ",").match(/^,?(.+),?$/)[1];
      }
    } catch(e) {}
  }
  return '0,0,0';
}

var version = getFlashVersion().split(',').shift();
if(version < 10){
  alert("Lower than 10");
}else{
  alert("10 or higher");
}
2
On

You would want to have a look at http://code.google.com/p/swfobject/ . It is an actively used javascript library for flash embedding. You would not have to deal with cross browser issues. Using SWFObject,flash version detection is as simple as :

function flashdetect(){
  var version = deconcept.SWFObjectUtil.getPlayerVersion();
  var major_version = version["major"];
  var revision = version["rev"];
}