Mark Smit
Status: Curious
Joined: 25 May 2005
Posts: 6
Location: Netherlands
Back to top
Posted: May 25, 05, 5:14    Suggestion for full-featured JavaScript detection script
Good work on the detection script. I discovered a minor issue with the Netscape 4/Mac detection (I was surprised to still have it installed on an old Classic partition and couldn't resist testing it).

When the current detection code is run before the document loads (i.e., from the <head> of the page), the current script fails.

I fixed this by making the document.layers test more specific and reversing the if-statement:

// OLD:
if ( !document.layers ) {
// ...
} else {
// Netscape4
}

// NEW:
if (typeof document.layers == "object") {
// Netscape4
} else {
// ...
}

I have found this to work well. Does anybody see any disadvantages?
Display posts from previous:   

All times are GMT - 8 Hours