Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/411.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 简单闪光检测_Javascript_Flash_Browser - Fatal编程技术网

Javascript 简单闪光检测

Javascript 简单闪光检测,javascript,flash,browser,Javascript,Flash,Browser,我知道Adobe的Flash检测工具包——但有没有办法简单地确定访客是否安装/支持Flash?如果浏览器支持Flash,那太好了,但我不在乎哪个版本。我正在努力找到一个简单的JavaScript代码来实现这一点。有人见过这样的东西吗? 干杯 函数detectPlugin(){ //允许一次通过多个检查 var daPlugins=detectPlugin.arguments; //认为插件被证明是假的,直到证明是真的 var pluginound=false; //如果插件阵列存在并且不是假的

我知道Adobe的Flash检测工具包——但有没有办法简单地确定访客是否安装/支持Flash?如果浏览器支持Flash,那太好了,但我不在乎哪个版本。我正在努力找到一个简单的JavaScript代码来实现这一点。有人见过这样的东西吗? 干杯


函数detectPlugin(){
//允许一次通过多个检查
var daPlugins=detectPlugin.arguments;
//认为插件被证明是假的,直到证明是真的
var pluginound=false;
//如果插件阵列存在并且不是假的
if(navigator.plugins&&navigator.plugins.length>0){
var pluginsraraylength=navigator.plugins.length;
//对于每个插件。。。
for(pluginArrayCounter=0;pluginArrayCounter=0)|
(navigator.plugins[pluginsaraycounter].description.indexOf(daPlugins[namesCounter])>=0){
//找到了这个名字
numFound++;
}   
}
//现在我们已经根据这个插件检查了所有必需的名称,
//如果我们找到的数字与提供的总数匹配,那么我们成功了
if(numFound==daPlugins.length){
pluginound=true;
//如果我们找到了这个插件,我们就可以停止浏览其余的插件了
打破
}
}
}
返回pluginFound;
}//detectPlugin
函数detectFlash(){
pluginound=detectPlugin('Shockwave','Flash');
//如果未找到,请尝试使用VisualBasic进行检测
if(!pluginound&&detectableWithVB){
pluginFound=detectActiveXControl('shockwavelash.shockwavelash.1');
}
//检查重定向
if(pluginound){
警惕(“你有闪光灯”);
}
}
detectFlash();
改编自:

“一个(纯)JavaScript库,旨在简化检测 Adobe Flash Player安装在Web浏览器中。”


请将
var
放在
pluginsArrayCounter=0前面。另外,将
navigator.plugins
的引用保存到局部变量也不会有任何影响。谢谢,我确实知道这一点。。。但这并不简单!
<script language="JavaScript">

function detectPlugin() {
    // allow for multiple checks in a single pass
    var daPlugins = detectPlugin.arguments;
    // consider pluginFound to be false until proven true
    var pluginFound = false;
    // if plugins array is there and not fake
    if (navigator.plugins && navigator.plugins.length > 0) {
    var pluginsArrayLength = navigator.plugins.length;
    // for each plugin...
    for (pluginsArrayCounter=0; pluginsArrayCounter < pluginsArrayLength; pluginsArrayCounter++ ) {
        // loop through all desired names and check each against the current plugin name
        var numFound = 0;
        for(namesCounter=0; namesCounter < daPlugins.length; namesCounter++) {
        // if desired plugin name is found in either plugin name or description
        if( (navigator.plugins[pluginsArrayCounter].name.indexOf(daPlugins[namesCounter]) >= 0) || 
            (navigator.plugins[pluginsArrayCounter].description.indexOf(daPlugins[namesCounter]) >= 0) ) {
            // this name was found
            numFound++;
        }   
        }
        // now that we have checked all the required names against this one plugin,
        // if the number we found matches the total number provided then we were successful
        if(numFound == daPlugins.length) {
        pluginFound = true;
        // if we've found the plugin, we can stop looking through at the rest of the plugins
        break;
        }
    }
    }
    return pluginFound;
} // detectPlugin



function detectFlash() {
    pluginFound = detectPlugin('Shockwave','Flash'); 
    // if not found, try to detect with VisualBasic
    if(!pluginFound && detectableWithVB) {
    pluginFound = detectActiveXControl('ShockwaveFlash.ShockwaveFlash.1');
    }
    // check for redirection
    if (pluginFound) {
    alert ("You has teh flash");
    }
}
detectFlash();

</script>