A very good article on this comes from Quirksmode: http://www.quirksmode.org/js/support.html
The script supplied by 'lajuette' is good but it doesn't make you much smarter. The same author explain his thinking behind the script in the above link and basically what he says is:
- It is not about browser detection
- It is about object detection
- This leads to the knowledge of which browser is used.