浏览器检测插件-检测Flash

//检测插件 (ie 中无效)

function hasPlugin( name ){

   name = name.toLowerCase();

       for (var i =0; i<navigator.plugins.length; i ++) {

     if (navigator.plugins[i].name.toLowerCase().indexOf(name) > -1 ) {

            return true;

        }

     }

     return false;

}

//检测 Flash

alert( hasPlugin('Flash') )

//检测 QuickTime

alert( hasPlugin("QuickTime") )

//检测IE中插件 COM对象检测插件 使用唯一标识符

 function hasIEPlugin( name ){

    try{

       new ActiveXObject(name);

           return ture;

   } catch( ex ){

       return false;

   }

}

//检测IE Flash

alert( hasIEPlugin( "ShockwaveFlash.ShockwaveFlash") )

//检测 QuickTime

alert( hasIEPlugin( "QuickTime.QuickTime" ) )

//检测所有浏览器中的Flash

function hasFlash () {

         var result = hasFlash("Flash");

             if( !result) {

       result = hasIEPlugin("ShockwaveFlash,ShockwaveFlash");

    }

    return result;

}

alert( hasFlash() )

猜你喜欢

转载自www.cnblogs.com/liufl/p/9383079.html