Last active
August 29, 2015 13:57
-
-
Save marksy/9764996 to your computer and use it in GitHub Desktop.
Adds class to HTML tag if userAgent is ipad/iphone/ipod
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.