Skip to content

Instantly share code, notes, and snippets.

@simplelife7
Last active August 29, 2015 14:07
Show Gist options
  • Save simplelife7/dd14099f4d8f5003d684 to your computer and use it in GitHub Desktop.
Save simplelife7/dd14099f4d8f5003d684 to your computer and use it in GitHub Desktop.
【JS】判断补全CSS3属性浏览器前缀
//source:http://www.webhek.com/vendor-prefix/
//return: {dom: "WebKit", lowercase: "webkit", css: "-webkit-", js: "Webkit"}
var prefix = (function () {
var styles = window.getComputedStyle(document.documentElement, ''),
pre = (Array.prototype.slice
.call(styles)
.join('')
.match(/-(moz|webkit|ms)-/) || (styles.OLink === '' && ['', 'o'])
)[1],
dom = ('WebKit|Moz|MS|O').match(new RegExp('(' + pre + ')', 'i'))[1];
return {
dom: dom,
lowercase: pre,
css: '-' + pre + '-',
js: pre[0].toUpperCase() + pre.substr(1)
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment