That one example shows some of the hoops you have to go through to detect browsers. Getting it right is all about experimentation.
Browser detection is never a perfect science and as time goes by you may need to tweak and change your detection method. The example here might not even be perfect. You'll need to test it on as many browsers as you can to make sure you've got it right.