A friend posted an article about how the flash detection on CNN is failing for Flash Player 10 on certain browsers. This immediately sparked my interest as I have taken it upon myself to make sure he understands that Flash Player isn’t just another pile of proprietary software.
Anyways, I checked it out, and my first immediate guess was that detection was failing due to the browser he was using, but I realized what it was more likely to be when I drifted off into a thought tangent at work. 10 is less than 9 when they are compared as strings. I figured, if this just occurred, then all this time their detection script was succeeding because comparing integers 0-9 as strings yields the same result as comparing them as integers.
I’m pretty certain of this, I actually went ahead and looked at the source:
http://i.cdn.turner.com/cnn/.element/js/2.0/main.js
and had a look at the class CNN_FlashDetect, and specifically the following function:
CNN_FlashDetect.prototype.detectVersion = function ( num ) { var isVersionSupported = false; if ( ! isNaN( num ) ) { isVersionSupported = ( this.getVersion() >= parseInt( num ) ); } //this alert was added by me alert([this.getVersion(), num, typeof(this.getVersion()), typeof(num), isVersionSupported]); //10.0.0,9,string,number,false return ( isVersionSupported ); }
This script is designed to just test major versions as parseInt(num) hints at. Unfortunately, “10.0.0″ is not being converted to a number, which seems like something that should have been done at getVersion() by virtue of detectVersion()’s task. It isn’t actually a valid number, so it is not converted for >=. Instead, 9 is converted to a string for comparison, which is the crux of the issue. I tested this script in IE. Running FP10 on IE6, the script reports 8 as my flash player version and is a number…
Consistency makes me all fuzzy inside.
Now, I know this site works on IE6, and that is because it’s actually testing for version 8 instead of 9 as the minimum version.
As far as I can tell, the site is actually loading the adobe detection script – which also doesn’t seem to be working. The detection script returns -1 when it tries to detect flash for IE6 when running fp10. I haven’t tested it for other versions, but I would figure it would do the same. Apparently the version you have installed precedes the existence of flash player. I tested some vars, and it looks like the script is failing to initialize bools that allow the detection scripts to determine which browser they’re in. None of the detection conditions are met, so it returns -1. This doesn’t seem to have anything to do with flash player 10.
The CNN script tries 3 detection techniques, all of which are dynamic with limits – js/vb for active x, and a word search for plugin flash player. For active x, the script tries to create different versions of the flash player in a try catch, and when it succeeds, the iterator is used as the player version, so we get a number in IE, which is typically 8 which is the upper bound of the function. For plugins, it does a word search on the description property of the plugin and uses isNaN to test if parseInt() succeeded in converting a word to a number. When this succeeds though the assigned variable to the result is not parsed, so we get a string…
The truth is, “10.0.0″ IS < "9". It turns out that the issue is implementation specific. It has nothing to do with browsers or the flash player... !
0 Response to “CNN Fails Flash 10 Detection”