Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Custom Modernizr tests that are useful.
/* modernizr-ios-check.js
* Daniel Ott (with modifications)
* 3 March 2011
* Custom Tests using Modernizr's addTest API
*/
/* iOS
* There may be times when we need a quick way to reference whether iOS is in play or not.
* While a primative means, will be helpful for that.
*/
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