Skip to content

Instantly share code, notes, and snippets.

@thunsaker
Forked from danott/modernizr-tests.js
Last active April 27, 2016 21:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thunsaker/8bc54ffe6dc7292923ab3874abafab36 to your computer and use it in GitHub Desktop.
Save thunsaker/8bc54ffe6dc7292923ab3874abafab36 to your computer and use it in GitHub Desktop.
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