<script type="text/javascript"> function doDevice () { var agent = navigator.userAgent; if (agent.indexOf('Windows') > 0) { // it's windows platform } else if (agent.indexOf('Android') > 0){ // it's android platform } else if (agent.indexOf('iPhone') > 0) { // it's iPhone platform } } </script>
A expert on system architect with full SDLC and Agile development experience. Skills: , C# C++ Scrum OOA/OOD javascript ASP.Net MVC XML, HTML Web Service, RESTful, WCF, Android and etc. Email me if you need help on development.
Monday, 5 September 2011
Detect Browser or User Agent from Client-side using JavaScript
Optimized or tweaked your website for particular device platform, such as iPhone, Android, Windows 7 and etc., becomes more and more critical for improving user experience and attracting more traffic to your website. Usually it makes more sense to detect user browser or user agent on server side in order to redirect traffic to your well built device specific version of your main site as well as regular PC or Mac users. But there is always a case that client-side detection is more handy. Furthermore, it's very easy to do it using JavaScript and is supported by almost every browser platform.
Labels:
javascript
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment