Sniffing the Browser
Problem 1: How do I determine which browser a person is using?
Believe it or not, determining the browser isn't all that important. What is important is what objects the browser supports. There are plenty of browser sniffers out there that use the navigator object to determine the exact browser manufacturer and version. The problem with all of those navigator-based sniffers is that if the browser maker changes the settings the sniffer will fail. Instead, use object detection to make your scripts forward compatible:
//Netscape 4 specific code
//Netscape 6 specific code
//IE4+ specific code
Even though IE5 supports the getElementById() function, if you are careful with your code, you can force IE5 to run only the appropriate code (see the next topic Writing Cross-Browser Scripts).