Blog

Browser Sniff if on Apple Device using JavaScript
Posted on May 16, 2019 in JavaScript by Matt Jennings

Details from StackOverflow.com Device Detect Variables

What is the list of possible values for navigator.platform as of today? – from StackOverflow.com

JavaScript

var deviceDetect = navigator.platform;
var appleDevicesArr = ['MacIntel', 'MacPPC', 'Mac68K', 'Macintosh', 'iPhone', 'iPod', 'iPad', 'iPhone Simulator', 'iPod Simulator', 'iPad Simulator', 'Pike v7.6 release 92', 'Pike v7.8 release 517'];

// If on Apple device
if(appleDevicesArr.includes(deviceDetect)) {
    // Execute code
}
// If NOT on Apple device
else {
    // Execute code
}

 

Leave a Reply