Skip to content

Instantly share code, notes, and snippets.

@ltchronus
Created February 7, 2015 06:20
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 ltchronus/0183a5d199e9444e6fd1 to your computer and use it in GitHub Desktop.
Save ltchronus/0183a5d199e9444e6fd1 to your computer and use it in GitHub Desktop.
get browser's prefix
function getVendorPrefix() {
// 使用body是为了避免在还需要传入元素
var body = document.body || document.documentElement,
style = body.style,
vendor = ['webkit', 'khtml', 'moz', 'ms', 'o'],
i = 0;
while (i < vendor.length) {
// 此处进行判断是否有对应的内核前缀
if (typeof style[vendor[i] + 'Transition'] === 'string') {
return vendor[i];
}
i++;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment