Is there a way to detect if the current user is using an iPad using jQuery/JavaScript?
Thanks everyone!
Is there a way to detect if the current user is using an iPad using jQuery/JavaScript? Thanks everyone! |
||||
|
The following should help you out with detecting an iPad user:
Related: (detects iPhone or iPod)
Here are a few links related to this topic: (includes jQuery, JavaScript and PHP solutions): jQuery HowTo: Detect iPad users using JavaScript jQuery HowTo: Detecting & Redirecting iPad / iPhone Users |
|||||||||||||||||||||
|
I use this:
|
|||
|
Although the accepted solution is correct for iPhones, it will incorrectly declare both The conventional wisdom is that iOS devices have a user agent for Safari and a user agent for the UIWebView. This assumption is incorrect as iOS apps can and do customize their user agent. The main offender here is Facebook. Compare these user agent strings from iOS devices:
Note that on the iPad, the Facebook UIWebView's user agent string includes 'iPhone'. The old way to identify iPhone / iPad in JavaScript:
If you were to go with this approach for detecting iPhone and iPad, you would end up with IS_IPHONE and IS_IPAD both being true if a user comes from Facebook on an iPad. That could create some odd behavior! The correct way to identify iPhone / iPad in JavaScript:
We declare IS_IPHONE to be false on iPads to cover for the bizarre Facebook UIWebView iPad user agent. This is one example of how user agent sniffing is unreliable. The more iOS apps that customize their user agent, the more issues user agent sniffing will have. If you can avoid user agent sniffing (hint: CSS Media Queries), DO IT. |
|||||
|
I use this:
|
||||
|