Skip to content

Instantly share code, notes, and snippets.

@carloscabo
Created March 28, 2017 13:50
Show Gist options
  • Save carloscabo/0ec69aaa42216c7f12efd861e110cb8b to your computer and use it in GitHub Desktop.
Save carloscabo/0ec69aaa42216c7f12efd861e110cb8b to your computer and use it in GitHub Desktop.
JS Detect Safari on iOS devices
(function(){
var
is_ios = /iP(ad|od|hone)/i.test(window.navigator.userAgent),
is_safari = !!navigator.userAgent.match(/Version\/[\d\.]+.*Safari/);
if ( is_ios && is_safari ) {
var
$html = document.documentElement,
classes = $html.className.concat(' is-ios-safari');
$html.className = classes;
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment