브라우저에 flash 플러그인 설치 여부 판단

1420 단어 Flash

function flashChecker()
{
    var hasFlash=0;         // flash
    var flashVersion=0; //flash 
    var isIE= (navigator.userAgent.indexOf('MSIE') != -1);      // IE 

    if(isIE)
    {
        var swf = new ActiveXObject('ShockwaveFlash.ShockwaveFlash'); 
        if(swf) {
            hasFlash=1;
            VSwf=swf.GetVariable("$version");
            flashVersion=parseInt(VSwf.split(" ")[1].split(",")[0]); 
        }
    }else{
        if (navigator.plugins && navigator.plugins.length > 0)
        {
            var swf=navigator.plugins["Shockwave Flash"];
            if (swf){
                hasFlash=1;
                var words = swf.description.split(" ");
                for (var i = 0; i < words.length; ++i){
                    if (isNaN(parseInt(words[i])))
                        continue;
                    flashVersion = parseInt(words[i]);
                }
            }
        }
    }
    return {hasFlash:hasFlash,v:flashVersion};
}

//usage:
var fls = flashChecker();
if(fls.hasFlash){
  alert(" flash : "+fls.v+".x");  
} else{
  alert(" flash");   
} 

좋은 웹페이지 즐겨찾기