Pratikshya
Pratikshya

Reputation: 202

How to detect if a device is an iPad?

Is it possible to detect whether a browser is running on iOS (I want to know if the device is an iPad) by using feature detect with Modernizr. Like it adds lt-ie8 class for IE8. I want to know what it sticks to <html> class if the device is an iPad.
I just want to add css classes exclusively for iPad.

Upvotes: 0

Views: 332

Answers (2)

Sumit Maingi
Sumit Maingi

Reputation: 2263

via the user-agent header.

Copied from google search, I searched for user-agent ipad.

User-Agent String   Apple Product   iOS Version Build
Apple-iPad1C1/807.4 iPad    4.3.1   8G4 Mar 25, 2011
Apple-iPad1C1/808.7 iPad    4.3.2   8H7 Apr 14, 2011
Apple-iPad1C1/810.3 iPad    4.3.3   8J3 May 4, 2011
Apple-iPad1C1/811.2 iPad    4.3.4   8K2 Jul 15, 2011

Basically you should search for Apple-Ipad* in the user-agent header.

Upvotes: 0

Samantha Ingram
Samantha Ingram

Reputation: 114

You can use Modernizer to declare a class on the body or html tag when a person is viewing a certain browser.

From there you can declare those classes within your stylesheet.

https://modernizr.com/docs#using-modernizr-with-css

Upvotes: 1

Related Questions