Skip to content

Instantly share code, notes, and snippets.

@dreamyguy
Last active April 9, 2018 11:30
Show Gist options
  • Save dreamyguy/7005582 to your computer and use it in GitHub Desktop.
Save dreamyguy/7005582 to your computer and use it in GitHub Desktop.
Modernizr tests to detect iOS devices.
// iOS Detection
// Clumsy but handy way to detect iOS devices and refer to them when needed.
Modernizr.addTest('ipad', function () {
return !!navigator.userAgent.match(/iPad/i);
});
Modernizr.addTest('iphone', function () {
return !!navigator.userAgent.match(/iPhone/i);
});
Modernizr.addTest('ipod', function () {
return !!navigator.userAgent.match(/iPod/i);
});
Modernizr.addTest('ios', function () {
return (Modernizr.ipad || Modernizr.ipod || Modernizr.iphone);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment