使用JavaScript检测Flash版本

3
如何使用JavaScript检测浏览器使用的Flash版本?

我认为这就是你要找的东西:Adobe Flash Detection Kit - KJYe.Name
可能是重复的问题:如何使用JavaScript检查Flash Player版本? - mipe34
2个回答

7
有一个不错的、轻量级的JavaScript Flash检测库,它比使用SWFObject更小更方便。如果你只想检查Flash是否已安装,但正在使用不同的方法播放FLV电影,应该考虑使用它。 SWFObject应该仅在您还将其用于播放Flash电影时才予考虑。仅仅是为了检查Flash是否已安装,我认为它太重了。

2
这里有很多关于JavaScript Flash Detection Library的内容,但它似乎可以简化为以下这样:
getFlashVer: function () {
    var activeXObj, plugins, plugin, result;

    if (navigator.plugins && navigator.plugins.length > 0) {
        plugins = navigator.plugins;
        for (var i = 0; i < plugins.length && !result; i++) {
            plugin = plugins[i];
            if (plugin.name.indexOf("Shockwave Flash") > -1) {
                result = plugin.description.split("Shockwave Flash ")[1];
            }
        }
    } else {
        plugin = "ShockwaveFlash.ShockwaveFlash";
        try {
            activeXObj = new ActiveXObject(plugin + ".7"), result = activeXObj.GetVariable("$version")
        } catch (e) {}

        if (!result) try {
            activeXObj = new ActiveXObject(plugin + ".6"), result = "WIN 6,0,21,0", activeXObj.AllowScriptAccess = "always", result = activeXObj.GetVariable("$version")
        } catch (e) {}

        if (!result) try {
            activeXObj = new ActiveXObject(plugin), result = activeXObj.GetVariable("$version")
        } catch (e) {}

        result && (result = result.split(" ")[1].split(","), result = result[0] + "." + result[1] + " r" + result[2])
    }
    return result ? result : "-";
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接