Check out the Javascript Navigator object:
http://www.w3schools.com/js/js_browser.asp
alert(navigator.userAgent);
This script may help you for more complicated detection:
http://www.quirksmode.org/js/detect.html
You should be handling these redirections server-side though. This is particularly true if you have a mobile version of your site. Most mobile browsers do support Javascript just fine, but there are quirks.
Server-side, you can send a redirect by sending the 302 status code, and the location:
header. See http://en.wikipedia.org/wiki/HTTP_location
Edit: Since you say that you need to detect mobile browsers now in your comments, just use this script: http://detectmobilebrowsers.mobi/