Skip to content

Instantly share code, notes, and snippets.

@ryanburnett
Created December 19, 2013 15:18
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 ryanburnett/8040771 to your computer and use it in GitHub Desktop.
Save ryanburnett/8040771 to your computer and use it in GitHub Desktop.
conditionizr
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>conditionizr</title>
<script src="scripts/conditionizr.js"></script>
<script>
// Chrome
conditionizr.add('chrome', ['class'], function () {
return !!window.chrome && /google/i.test(navigator.vendor);
});
// Firefox
conditionizr.add('firefox', ['class'], function () {
return typeof InstallTrigger !== 'undefined';
});
// IE 10
conditionizr.add('ie10', ['class'], function () {
var version = false;
/*@cc_on
if (/^10/.test(@_jscript_version) && /MSIE 10\.0(?!.*IEMobile)/i.test(navigator.userAgent))
version = true
@*/
return version;
});
// IE 11
conditionizr.add('ie11', ['class'], function () {
return /(?:\sTrident\/7\.0;.*\srv:11\.0)/i.test(navigator.userAgent);
});
// Safari
conditionizr.add('safari', ['class'], function () {
return /constructor/i.test(window.HTMLElement);
});
// iOS
conditionizr.add('ios', ['class'], function () {
return /(iPad|iPhone|iPod)/i.test(navigator.userAgent);
});
</script>
</head>
<body>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment