- 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;
- };
- })();
-
- if ( supports(‘textShadow‘) ) {
- document.documentElement.className += ‘ textShadow‘;
- }
【前端学习】检测浏览器是否支持这些属性
原文:http://www.cnblogs.com/lomo321/p/4381619.html