miscoded

the web is a hack

NVidia: lost in their own sniffer

If a user identifies as Opera and loads the NZone page on
<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.

blogger.com's browser detection unconvincingIDN baluba

Comments

qicai02 Friday, June 2, 2006 4:56:45 AM

newTitle? bigsmile

Write a comment

You must be logged in to write a comment. If you're not a registered member, please sign up.