开发者

get computed border radius in opera

I'm trying to get computed border-radius state of some element with this code:

function _elementCurrentStyle(element, styleName){
    if (element.currentStyle){
        var i = 0, temp = "", changeCase = false;
        for (i = 0; i < styleName.length; i++)
            if (styleName[i].toString() != '-'){
                temp += (changeCase ? styleName[i].toString().toUpperCase() : styleName[i].toString());
                changeCase = false;
            } else {
                changeCase = true;
            }
        styleName = temp;
        return element.currentStyle[styleName];
    } else {
        return getComputedStyle(element, null).getPropertyValue(styleName);
    }
}

    var borderRadius开发者_JAVA百科Check = ["-moz-border-radius-bottomright","border-radius","border-bottom-right-radius","-webkit-border-bottom-right-radius","-khtml-border-radius-bottomright","-khtml-border-bottom-right-radius"];
    var i = 0, temp = "";
    for (i = 0; i < borderRadiusCheck.length; i++){
        temp = _elementCurrentStyle(myElement, borderRadiusCheck[i]);
        if (temp)
            break;
    }

The variable "myElement" is a HTML element with border-radius set to "20px". (Either by setting it dynamically and with CSS)

The "temp" variable contains the borderRadius ("20px") string. This code works under IE, FF and Chrome, but under Opera, I get an empty string when trying to get "border-radius" or "border-bottom-right-radius", and when calling with others it returns "undefined".

It doesn't matter if I get border-radius or border-bottom-right-radius because all borders of this HTML element are the same.

Have You got any idea, which style property name should I call for to get the radius?

Thanks for Your help.


Opera supports border-radius. When using Opera Dragonfly, you can notice that

border-radius: 10px;

gets transformed as

border-bottom-left-radius: 10px;
border-bottom-right-radius: 10px;
border-top-left-radius: 10px;
border-top-right-radius: 10px;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜