Created
July 25, 2012 15:15
-
-
Save Mr2P/3176712 to your computer and use it in GitHub Desktop.
Detect CSS3 Support
This file contains hidden or 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
| //Jeffrey Way | |
| //http://net.tutsplus.com/tutorials/html-css-techniques/quick-tip-detect-css-support-in-browsers-with-javascript/ | |
| var supports = (function() { | |
| var div = document.createElement('div'), | |
| vendors = 'Khtml Ms O Moz Webkit'.split(' '), | |
| len = vendors.length; | |
| return function(prop) { | |
| if ( prop in div.style ) return true; | |
| prop = prop.replace(/^[a-z]/, function(val) { | |
| return val.toUpperCase(); | |
| }); | |
| while(len--) { | |
| if ( vendors[len] + prop in div.style ) { | |
| // browser supports box-shadow. Do what you need. | |
| // Or use a bang (!) to test if the browser doesn't. | |
| return true; | |
| } | |
| } | |
| return false; | |
| }; | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment