Sniff Your Users Version of Flash with Javascript
I ran across this on a website I hit this morning and found it to be quite useful. So I am reposting it here in case anyone else is trying to do this. In a nutshell, this bit of javascript will return a decimal value of the highest version of the Flash Player installed on an end users system. You can even specify the minimum version you are looking for and get a boolean TRUE or FALSE in return. Very slick.
// If called with no parameters this function returns a floating point value // which should be the version of the Flash Player or 0.0 // ex: Flash Player 7r14 returns 7.14 // If called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision) { reqVer = parseFloat(reqMajorVer + "." + reqRevision); // loop backwards through the versions until we find the newest version for (i=25;i>0;i--) { if (isIE && isWin && !isOpera) { versionStr = VBGetSwfVer(i); } else { versionStr = JSGetSwfVer(i); } if (versionStr == -1 ) { return false; } else if (versionStr != 0) { if(isIE && isWin && !isOpera) { tempArray = versionStr.split(" "); tempString = tempArray[1]; versionArray = tempString .split(","); } else { versionArray = versionStr.split("."); } versionMajor = versionArray[0]; versionMinor = versionArray[1]; versionRevision = versionArray[2]; versionString = versionMajor + "." + versionRevision; // 7.0r24 == 7.24 versionNum = parseFloat(versionString); // is the major.revision >= requested major.revision AND the minor version >= requested minor if ( (versionMajor > reqMajorVer) && (versionNum >= reqVer) ) { return true; } else { return ((versionNum >= reqVer && versionMinor >= reqMinorVer) ? true : false ); } } } return (reqVer ? false : 0.0); }
11 Dec 2007 04:24 pm Chris 0 comments