前端實現獲取瀏覽器flash版本號

getFlashVersion() {
            var flashVer = NaN;
            var ua = navigator.userAgent;

            if (window.ActiveXObject) {
              var swf = new ActiveXObject('ShockwaveFlash.ShockwaveFlash');

              if (swf) {
                 flashVer = Number(swf.GetVariable('$version').split(' ')[1].replace(/\,/g, '.').replace(/^(\d+\.\d+).*$/, "$1"));
              }
            } else {
             if (navigator.plugins && navigator.plugins.length > 0) {
                 var swf = navigator.plugins['Shockwave Flash'];

                 if (swf) {
                     var arr = swf.description.split(' ');
                     for (var i = 0, len = arr.length; i < len; i++) {
                         var ver = Number(arr[i]);

                         if (!isNaN(ver)) {
                            flashVer = ver;
                            break;
                         }
                     }
                 }
             }
            }
            return flashVer;
        }
        
複製代碼
相關文章
相關標籤/搜索