What's the best way to detect browser?

Hey all,
I’m looking for the best way to detect browser, especially I’m looking
to distinguish browsers as three different groups:
ie6 and older, netscape4 and older browsers
ie7
khtml/webkit/gecko/opera browsers

any idea?

thanx in advance

Pat

Don’t know if it’s the best way, but you can get the User-Agent in the
controller with request.env[‘HTTP_USER_AGENT’].

b

Will this work?

case request.user_agent
when /(gecko|opera|konqueror|khtml|webkit)/i
return :gecko
when /msie\s+7.\d+/i
return :ie7
else
return :older_browser
end

Check out JavaScript - Browser detect for a nice piece of
Javascript code to detect on the client side.

http://www.agilewebdevelopment.com/plugins/browser_detect