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 に答える