I’m working on my Web site and now that the Apple iPad is out, I’d like to customize my greeting for people using that device. How can I auto-detect that they’re on an iPad?
There are a ton of tools to help you with this particular task, and I’ve written about it before too (see How to detect an iPhone web browser). The basic idea is that every Web browser on every hardware platform sends what’s called a USER_AGENT identifier. Almost all of the time they’re accurate, but some test browsers have the ability to pretend they’re something else (known in the biz as “spoofing”, actually).
On my Mac OS X system, for example, when I am hitting Web pages within Google’s Chrome browser, here’s what is sent to the Web server for each and every transaction I do, whether an HTML page, PHP search result or even ask for a photo or other image:
Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-US) AppleWebKit/533.2 (KHTML, like Gecko) Chrome/5.0.347.0 Safari/533.2
You can check your Web browser too. Just pop over to Microsystools and find out.
Now, the question of the moment is, what string does it show when you’re on an Apple iPad?
Here’s the answer:
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/7B367 Safari/531.21.10
Pretty ugly, really, but the key thing to notice is that the first word within parens identifies the hardware platform. If you’re writing code of some sort, simply grab the USER_AGENT string, then check that first word.
Oh, if you’re on an iPhone and you go to the same page, here’s the USER_AGENT you are sending on each query:
Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_1_3 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version /4.0 Mobile/7E18 Safari/528.16
Looking for iPad help? Good news; you’ve found it!