Detecting iPhone, iPod, iPad, Android and BlackBerry with JavaScript and PHP

Detecting mobile browsers may be useful in case you want to show a special download link or a promotion for someone going mobile. In pure javascript, the implementation is dead simple. Here we have example user agents of mobile browsers:

So, as we see, all we need is find those special iPod or Android strings in user agent, something like this:

And then we can do like this:

For PHP we can use same technique, except that user agent will be retrieved like this:

And then using it like this

Resource: Graphicmaniacs

Leave a Reply

Your email address will not be published. Required fields are marked *