Skip to content

Instantly share code, notes, and snippets.

@marksy
Last active August 29, 2015 13:57
Show Gist options
  • Save marksy/9764996 to your computer and use it in GitHub Desktop.
Save marksy/9764996 to your computer and use it in GitHub Desktop.
Adds class to HTML tag if userAgent is ipad/iphone/ipod
var iOS = (navigator.userAgent.match(/(iPad|iPhone|iPod)/g) ? true : false);
console.log('Is the userAgent iOS: ' + iOS);
if (iOS) {
console.log('The userAgent is probably iOS');
$('html').addClass('mobile-safari');
} else {
console.log('This userAgent aint no iOS');
}
@marksy
Copy link
Author

marksy commented Mar 25, 2014

Not the best idea considering userAgent can be easily spoofed. But some stupid/simple styling on iOS Safari (forms) sometimes requires to be styled additionally to client request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment