Home » iOS » JavaScript for detecting iOS devices

JavaScript for detecting iOS devices

Simple JavaScript for detecting iOS devices

1
2
3
4
5
6
7
8
var deviceAgent = navigator.userAgent.toLowerCase();
var iOS = deviceAgent.match(/(iphone|ipod|ipad)/);
       
if (iOS) {
   // iOS
} else {
  // not iOS
}