1

I'm looking to detect a specific model of iPad via Javascript (iPad v. iPad 2 v. iPad Mini v..., etc).

This information is not contained in the user agent. Some iPads have Retina, some don't.

If possible, the ability to distinguish iPhone types as well would be helpful.

Is this possible?

xd1936
  • 1,038
  • 2
  • 9
  • 27

2 Answers2

0

To detect retina display use window.devicePixelRatio.

To detect iPad version use data at UA. Watch this answer. This list of iDevices UAs would helps you to find solution. As you see each model has it's own build number, you can use it for your purposes.

Community
  • 1
  • 1
Paul Rumkin
  • 6,737
  • 2
  • 25
  • 35
  • I wish this were the case, but the iPhone user agent doesn't actually give the model number! `Mozilla/5.0 (iPhone; CPU iPhone OS 7_0 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53` – xd1936 Feb 17 '14 at 19:17
0

I don't think there's any way to detect a specific iPad model

But you can use CSS query to apply styles for retina devices, like

@media (-webkit-min-device-pixel-ratio: 2) {
    background-image: url(bg_@2X.png);
}

Hope it helps.

akasfei
  • 67
  • 8