How to detect web request from iPad?

With iPad sales soaring and lot of people using iPad to browse your web site, you want to make sure that your site is ready for iPad. Since the size of iPad is not as small as mobile device like iPhone, iPod, Droid etc. so you need to make sure that your site is not serving content intended for those small devices.

First and foremost thing that you need is a way to detect if web request is coming from iPad. We all look at User Agent string sent by browser in headers. Following is user agent string that is sent by iPad.

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

The main indetification mark in this string is presence of iPad. So if you have a regular expression or some string search function, then look for presence of iPad sub-string in user agent string to determine if this request is coming from iPad. There are few things that makes it essential to search for iPad in this string.

  • Mac, iPhone use Safari browser. That would mean that you need some other identification to distinguish between request browser.
  • iPhone browser user agent looks the same but with a difference that it has iPhone sub-string embedded in user agent string. But for iPad, the user agent string is identified by presense of Mobile in the string.

Search

Social

Weather

15.5 °C / 60.0 °F

weather conditions Clouds

Monthly Posts

Blog Tags