Possible Duplicate:
How can I detect the browser with PHP or JavaScript?
I need to show different information in different browser ( Internet Explorer, Firefox, Chrome, Safari and Opera ). So I need a way to detect the user’s browser.
What is the best way to do that in my case ?
I could use PHP or Javascript but I want to avoid to use external library like jQuery.
Thanks 🙂
Browser detection is a really unreliable practice, and should be avoided. That being said, you typically get started by sniffing
navigator.userAgentin JavaScript, or checking the userAgent (orget_browser()) as it comes across with the requests to your server.However, don’t do this – please (for the ponies). Use feature detection instead. Tools like Modernizr make it very easy for you to deliver content up only when it’s supported, and to code around differences between browsers.