« links for 2006-05-13 | Main | links for 2006-05-14 »

Reading Quirksmode on assuring JavaScript compatibility across browsers

Today I made some notes about Quirksmode's page on cross-browser compatibility via Object detection.

Initially he says that it's better to not rely on JS that detects a particular browser. He recommends against branching code based on detecting the browser type or version; and rather testing for the functionality that is necessary to run the script. In practice, this means testing for objects.

Scroll to the bottom of the page for a discussion of which objects for which it has historically been most important to test.


I have code snippets from the 90's that I still use, which include the version number in the SCRIPT tag. But I've noticed that this practice seems to have died out, and it turns out it's because version numbers aren't really informative as to which features are available in a given browser.

I left Web development for bioinformatics research in the early part of the decade. When I came back to e-commerce, I found that cross-browser assurance had apparently evolved to become more complex, and then gotten simpler again. getElementById works in the two major browsers, but scripts still abound that use document.all and even document.layers. Thankfully I found that Quirksmode contains a good article on cross-browser issues at the beginning of the decade. Although I did skip the section on Netscape 4.

However it does seem to be the cas that document.all is no longer required (unless one expects to support IE 4). And most of my clients didnt' support Netscape 4 even when it was current. In fact, my current client still doesn't test on Netscape -- they don't get enough visitors using it to bother.