Skip to content

Instantly share code, notes, and snippets.

@TimPietrusky
Created June 9, 2013 17:23
Show Gist options
  • Save TimPietrusky/5744384 to your computer and use it in GitHub Desktop.
Save TimPietrusky/5744384 to your computer and use it in GitHub Desktop.
A CodePen by Tim Pietrusky. Detect Safari 6+ - With 2/3 dirt and 1/3 feature detection.
/**
Detect Safari 6+
With 2/3 dirt and 1/3 feature detection.
CSS filter are implemented in Safari 6+
http://caniuse.com/css-filters
Warning: userAgent stuff is bad.
But it should work in most of the cases.
Use at your own risk >:D
# 2013 by Tim Pietrusky
# timpietrusky.com
**/
var isSafari6 =
!!navigator.userAgent.match(/safari/i) &&
!navigator.userAgent.match(/chrome/i) &&
typeof document.body.style.webkitFilter !== "undefined";
document.body.innerHTML = isSafari6 ? 'this is Safari 6+' : 'this is NOT Safari 6+';
document.body.className = isSafari6 ? 'isSafari6' : 'not';
@import "compass";
@import url(http://fonts.googleapis.com/css?family=Trocchi);
body {
margin:1em 0;
font: 700 3.5em 'Trocchi' sans-serif;
letter-spacing:.075em;
color: #fff;
text-align:center;
&.isSafari6 {
background:#3d9d34;
}
&.not {
background:#bf4440;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment