NVidia: lost in their own sniffer
Monday, 7. February 2005, 14:54:54
<http://www.nzone.com/object/nzone_downloads_nvidia.html>
it is not possible to use the links "Demos", "Videos", "Screensavers", "Wallpapers" to see lists of download content.
The script detects browsers and sets a few variables - some for detection and some functional ones. One of the functional ones is called "layerRef" and is how the script remembers whether to use document.all (in IE4), document.layers (in Netscape 4) or document.getElementById - the standardised alternative supported by nearly all other modern browsers.
The following JavaScript does not work as expected:
.
.
else if (NS6 || NS7 || Mozilla)
eval(layerRef + "("listData").innerHTML = demoDataHTML;");
else
eval(layerRef + "["listData"].innerHTML = demoDataHTML;");
This is because "layerRef" has been set to document.getElementById but NS6, NS7 and Mozilla are all false when you identify as Opera.
Opera then tries to execute the final line which evaluates as:
document.getElementById["tableTitle"].innerHTML = newTitle;
Since that means they are calling a function with square brackets, the script fails.
Morale: if you mix two different types of sniffing: by browser name and by functionality - you risk getting lost in the messy branches of your script. Clean object detection is way better.









qicai02 # 2. June 2006, 04:56