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

2 thoughts on “Detecting iPhone, iPod, iPad, Android and BlackBerry with JavaScript and PHP

  1. Hi there, all is going nicely here and ofcourse every one is sharing information, that’s truly excellent, keep up
    writing.

  2. Good day I am so grateful I found your weblog, I really found you by accident, while I was searching on Digg for something else, Regardless I am here now and would just like to say
    thanks for a incredible post and a all round exciting blog
    (I also love the theme/design), I don’t have time to go
    through it all at the minute but I have bookmarked it
    and also added your RSS feeds, so when I have time I will be back
    to read a great deal more, Please do keep up the excellent jo.

Comments are closed.