Skip to content

Instantly share code, notes, and snippets.

@zhiqiang21
Created March 8, 2017 07:03
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 zhiqiang21/3fc89178cecb3560ddfbb3fc2e96debd to your computer and use it in GitHub Desktop.
Save zhiqiang21/3fc89178cecb3560ddfbb3fc2e96debd to your computer and use it in GitHub Desktop.
js判断浏览器是否支持css3属性
/**
* 判断浏览器是否支持某一个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