« It's Finally Here!! | Main | Half Life 2 »
Stupid JavaScript
Found this code in a script:
var isMinNS4 = document.layers
var ie=document.all&&navigator.userAgent.indexOf("Opera")==-1
var dom=document.getElementById&&!ie
&&navigator.userAgent.indexOf("Opera")==-1
But what's wrong with it?
The first line tests for layer compatibility with Netscape 4+ browsers, all fine there.
The next line checks for support of document.all which was introduced by Internet Explorer but supported by Opera, the line will reject Opera browsers.
The final line tests for the W3C DOM and the getElementById function, rejects IE and for some reason it also rejects Opera.
Netscape, IE, Safari and Gecko browsers should all pass through the checks fine, but Opera will never pass through, and therefore the code just won't run. Why the hell is Opera singled out? Who knows.
It's easily fixed though. Opera supports the W3C DOM correctly, and so should pass as "dom".
The 3rd line should be changed to read:
var dom=document.getElementById&&!ie
Then Opera can actually run the script without any problems.
Posted in Computers at 12:59


boink