【问题标题】:How to check for the presence of a specific version of flash player, when the system has many versions with same "Major Version", (in javascript)?当系统有许多具有相同“主要版本”的版本时,如何检查是否存在特定版本的 Flash Player(在 javascript 中)?
【发布时间】:2011-06-24 14:59:54
【问题描述】:

我必须通过我的 javascript 代码检查客户端计算机上是否安装了特定版本的 flash player 10.2.161.23。客户的系统有许多其他具有相同“主要版本”的版本,如 10.1.102.64 等。我尝试了以下代码 sn-p

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

        }

客户的系统上有 10.1.102.64 和 10.2.161.23,我上面的代码只能识别 10.1.102.64,但不能识别具有相同“主要版本号:”的其他版本。

我可以使用 新的吗 ActiveXObject("MacromediaFlashPaper.MacromediaFlashPaper"); 代替 Shockwaveflash.shockwaveflash。做 这有什么影响吗?闪光播放器 我要检测的版本是 64 位 版本。

谁能告诉我原因并解决这个问题。 提前致谢。

【问题讨论】:

    标签: internet-explorer flash javascript javascript-framework


    【解决方案1】:

    你会想看看 http://code.google.com/p/swfobject/ 。 它是一个积极使用的用于 Flash 嵌入的 JavaScript 库。你会 不必处理跨浏览器问题。 使用 SWFObject,flash 版本检测很简单:

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

    【讨论】:

    • 我是新手,如果我的问题很愚蠢,请原谅我。如何将 SWFObject 库添加到我的 javascript 代码中。如果我们下载一些 .JS 文件,然后将其包含在 src="library.js" 中。请告诉我。
    • 这并不傻,我们在某个地方都是初学者。这是code.google.com/p/swfobject/wiki/documentation 的完整帮助,它展示了如何包含 swfobject.js,以及如何使用它。 <script type="text/javascript" src="http://www.mysite.com/jsfolder/swfobject.js"></script> ,不要把它复制到你的 library.js 中,最好把它作为一个单独的文件,并在你网页的 标签中包含它。
    【解决方案2】:

    试试下面的脚本

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

    【讨论】:

      猜你喜欢
      • 2019-03-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-20
      • 1970-01-01
      • 2015-02-02
      • 2018-03-18
      相关资源
      最近更新 更多