js获取浏览器前缀

时间:2021-10-01 06:00:17
<script>
var div = null;
var _prefix = (function (temp) {
var prefix = ["webkit", "Moz", "o", "ms"];
var props = "";
for (var i = 0; i < prefix.length; i++) {
props = prefix[i] + "Transition";
if (temp.style[props] !== undefined) {
return "-" + prefix[i].toLowerCase() + "-";
}
}
return false;
})(document.createElement(div)); console.log(_prefix);
</script>