3

我被一个愚蠢的问题困住了。下面是我获取 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;
}

请帮忙!

4

1 回答 1

3

这是一个 Chrome 错误。这样我们就避免使用这个函数:

document.defaultView.getComputedStyle(el,null)
于 2012-08-13T10:33:52.607 回答