/*判断浏览器是否支持某个css属性*/ function SupportCss(attrName){ var i=0, arr = SupportCss.opt.aBrowser, eleStyle = SupportCss.opt.eleStyle; for(i;i<arr.length ;i++){ if(arr[i] + attrName in eleStyle){return true;} } return false; } /*构造函数静态属性*/ SupportCss.opt = { /*浏览器前缀*/ aBrowser : [‘‘, ‘-webkit-‘, ‘-Moz-‘, ‘-ms-‘, ‘-o-‘], /*页面对象*/ eleStyle : document.documentElement.style }; console.log(‘transition:‘,SupportCss(‘transition‘)); console.log(‘width:‘,SupportCss(‘width‘));
时间: 2024-11-05 14:53:08