Sometimes, we want to detect iPad Pro as iPad with JavaScript.
In this article, we’ll look at how to detect iPad Pro as iPad with JavaScript.
How to detect iPad Pro as iPad with JavaScript?
To detect iPad Pro as iPad with JavaScript, we can check various properties of navigator
.
For instance, we write:
const isIOS = () => {
if (/iPad|iPhone|iPod/.test(navigator.platform)) {
return true;
} else {
return navigator.maxTouchPoints &&
navigator.maxTouchPoints > 2 &&
/MacIntel/.test(navigator.platform);
}
}
const isIpadOS = () => {
return navigator.maxTouchPoints &&
navigator.maxTouchPoints > 2 &&
/MacIntel/.test(navigator.platform);
}
to define the isIOS
and isIpadOS
functions to check whether the device runs iOS or iPad OS.
In isIOS
, we check navigator.platform
or check whether there’re more than 2 touch points max supported by the device.
In isIpadOS
, we just check whether the max number of touch points.
Conclusion
To detect iPad Pro as iPad with JavaScript, we can check various properties of navigator
.