codeLover
codeLover

Reputation: 3810

How to programatically check if a particular version of flash player is installed or not using JavaScript.?

I have a java script code and I want to check if flash player is installed or not and if at all it is installed which version ? Requirement demands me to achieve this without using SWFObject. INstead I want to some simple javascript code. I used the following snippet:

currentVer = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.10");
        version = currentVer.GetVariable("$version");

But its throwing the error msg,

File name or class name not found during Automation operation

I want to achieve using javascript coding itself, without downloading any software for it like SWFObject. I am using IE. Kindly help me with this.

Upvotes: 0

Views: 2133

Answers (2)

jbcurtin
jbcurtin

Reputation: 1803

You have most of it right there, you're just missing the testing part of it. Unfortunately there isn't really a way to access a given property that tells you what you want. You have to try to create the object.

function getFlashVersion(){
 var flash = 'None';
 // Count down from 10.
 for(var i = 10; i > 0; i--)
 {
   try{
    flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+String(i));
   }catch(e){
     //console.log(e);
   }
   if(flash != 'None')
    return flash.GetVariable("$version");

 }
 return 0;
}

Upvotes: 2

T.J. Crowder
T.J. Crowder

Reputation: 1074188

Adobe has a whole kit for detecting and (optionally) upgrading the version of Flash, including HTML examples; you can find it here.

From that page:

The Flash® Player Detection Kit helps developers implement robust player detection for a variety of deployment environments by providing a set of templates and techniques to successfully detect the version of Flash Player installed on a user’s computer, and, if needed, to then install the latest version of Flash Player. The kit also includes a detailed explanation and sample files for implementing the new, player-based Flash Player Express Install experience.

Upvotes: 0

Related Questions