我遇到了一个愚蠢的问题。下面是我获取计算dom风格的代码。它在FireFox甚至IE上运行良好(惊讶)!但在chrome v17上速度太慢(慢20倍)。如何避免这个问题?
getCurrentStyle = function(el)
{
if (el.currentStyle)
return el.currentStyle;
else if (window.getComputedStyle)
return document.defaultView.getComputedStyle(el,null);
return null;
}
请帮忙!
答案 0 :(得分:3)
这是一个Chrome错误。这样我们就可以避免使用这个函数了:
document.defaultView.getComputedStyle(el,null)