Home > ipad, JavaScript, jquery > JavaScript to detect iPad visitors

JavaScript to detect iPad visitors

This post gives you a short JavaScript function to detect your iPad users.

Without any further ado, a javascript code to detect iPad users:

function isiPad(){
    return (navigator.platform.indexOf("iPad") != -1);
}

You can also detect browser version and some other stuff by parsing user agent string. Here is an iPad Safari’s user agent string for your reference:

Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10

Recently a friend of mine got himself an iPad and I couldn’t not notice how his internet browsing device preferences are changing (PC & iPad). More and more people are using hand held devices namely iPad to browse the internet. So it’s about time to show your iPad visitors some love and display your website designed specifically for iPad.

Let’s see how to do this. There are two way:

  1. Redirect iPad visitors
  2. Apply different CSS file for iPad users

Most of the posts on the internet related to iPad user detection are suggesting and showing you how to redirect (including myself in my previous iPhone & iPod detection post). However, I would recommend the second option, applying different CSS file.

You can apply the same technique described in applying different styling for javascript enabled browser with CSS post and apply different CSS rules for iPad visitors.

Contact:

bhavinrana07[@]gmail.com

Advertisements
  1. Coretta Brossman
    October 13, 2011 at 9:45 pm

    Found this site on google, very glad I did.

  2. Herera@gmail.com
    October 13, 2011 at 11:22 pm

    Going to send this to my friends, this is definitely worth a read!

  3. web design company
    October 25, 2012 at 8:56 am

    My brother recommended I would possibly like this web site. He was totally right. This put up actually made my day. You cann’t imagine simply how a lot time I had spent for this info! Thanks!

  4. March 6, 2013 at 7:41 am

    Hello there, interesting blogpost. I really enjoyed it.
    And also like your website. Do you get a lot of traffic
    to your blog. I suppose you have which such interesting
    content. If you like to monetize this traffic, I
    can help you. Checkout my blog http://www.blog.hivisits.
    com where you can find detailed info about it. Thanks for allowing
    me to post this.

  5. March 30, 2013 at 8:59 pm

    My brother recommended I might like this website. He was entirely right.
    This post truly made my day. You can not imagine simply how much time I had spent for this information!
    Thanks!

  6. April 2, 2013 at 3:43 pm

    On the other hand, a lot of priceless art work has been discovered
    from the trash plus in garden sales, that’s not saying your corporate stamped pocket watches could be the next Patek Philippe that marketed for $11 million bucks at Sotheby’s in
    Dec 1999. After you’ve gathered items in one spot, sit down and pick out a
    weekend to run your sale. 1 with the best ways in
    which you are able to get all of the information present on-line is to consider obtaining hold of a forum where such a
    topic is being discussed.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: