使用JavaScript检测Flash版本

Detect Flash version using JavaScript

本文关键字:版本 Flash 检测 JavaScript 使用      更新时间:2023-09-26

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

有一个很好的轻量级JavaScript Flash检测库,它比使用SWFObject更小更方便。你应该考虑一下,如果你只是想检查是否安装了Flash,但你正在使用不同的方法播放FLV电影。

SWFObject应该只考虑,如果你也用它来播放Flash电影。只是检查一下,如果安装了Flash,我认为很重。

在JavaScript Flash检测库中有很多东西,但它似乎可以简化为这样的东西:

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 : "-";
}