7

这个函数总是"0"在 IE 中返回

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;
}

但铬返回11.8.r800

如何在 IE 中检测 Flash Player 版本。

4

3 回答 3

7

我认为使用swfobject库会更好。使用这个库,您可以简单地执行以下操作来跨浏览器获取 Flash 版本:

// returns a JavaScript object
var playerVersion = swfobject.getFlashPlayerVersion(); 
// access the major, minor and release version numbers via their respective properties
var majorVersion = playerVersion.major; 
于 2013-08-17T06:11:53.473 回答
4

这是我的一个项目中使用的,

在 IE 上也很好用

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");
}
于 2013-08-17T06:13:59.943 回答
1

尝试这个

    var a, b, c, y ='length',v = "name",t = "indexOf",m = "match";
    if (c=window.navigator.plugins)
        for (var d = 0; d < c[y] && !b; d++) {
            var e = c[d]; - 1 < e[v][t]("Shockwave Flash") && (b = e.description) 
        }
    if (!b) try {
        a = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7"), b = a.GetVariable("$version")
    } catch (g) {}
    if (!b) try {
        a = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6"), b = "WIN 6,0,21,0", a.AllowScriptAccess = "always", b = a.GetVariable("$version")
    } catch (ca) {}
    if (!b) try {
        a = new ActiveXObject("ShockwaveFlash.ShockwaveFlash"), b = a.GetVariable("$version")
    } catch (l) {}
    b &&
        (a = b[m](/[\d]+/g)) && 3 <= a[y] && (b = a[0] + "." + a[1] + " r" + a[2]);
    console.log(b) || void 0
于 2014-01-30T18:56:28.477 回答