Created
March 8, 2017 07:03
-
-
Save zhiqiang21/3fc89178cecb3560ddfbb3fc2e96debd to your computer and use it in GitHub Desktop.
js判断浏览器是否支持css3属性
This file contains 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
/** | |
* 判断浏览器是否支持某一个CSS3属性 | |
* @param {String} 属性名称 | |
* @return {Boolean} true/false | |
* @version 1.0 | |
*/ | |
function supportCss3(style) { | |
var prefix = ['webkit', 'Moz', 'ms', 'o'], | |
i, | |
humpString = [], | |
htmlStyle = document.documentElement.style, | |
_toHumb = function (string) { | |
return string.replace(/-(\w)/g, function ($0, $1) { | |
return $1.toUpperCase(); | |
}); | |
}; | |
for (i in prefix) | |
humpString.push(_toHumb(prefix[i] + '-' + style)); | |
humpString.push(_toHumb(style)); | |
for (i in humpString) | |
if (humpString[i] in htmlStyle) return true; | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment