Checking Flash player version using Javascript


Answers

There is a nice, lightweight JavaScript Flash Detection Library, which is smaller and more convenient than using SWFObject. You should consider it, if you only want to check if Flash is installed, what version of Flash Player is installed etc., but you're using different method of playing FLV movies.

SWFObject should be considered only, if you're also using it for playing Flash movies. For just checking, if Flash is installed or what version of Flash player is installed, it is to heavy, in my opinion.

Question

This question already has an answer here:

Is it possible to check the version of the Flash Player installed in a browser using Javascript?




Cross Browser Flash Detection in Javascript

SWFObject is very reliable. I have used it without trouble for quite a while.




There is a lot of going on in JavaScript Flash Detection Library, but it seems it can be simplified to something like this:

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






I know this is an old post, but I've been looking for a while and didn't find anything.
I've implemented the JavaScript Flash Detection Library. It works very well and it is documented for quick use. It literally took me 2 minutes. Here is the code I wrote in the header:

<script src="Scripts/flash_detect.js"></script>
<script type="text/javascript"> 
 if (!FlashDetect.installed) {
    alert("Flash is required to enjoy this site.");         
 } else {
    alert("Flash is installed on your Web browser.");
 }
</script>        






Tags