As a quick fix for this problem, you can make a plugin (I think this
would classify as a plugin)
just add the following after you include jquery

jQuery.extend({
        curCSS: function(elem, prop, force) {
                var ret, stack = [], swap = [];

                // A helper method for determining if an element's values are 
broken
                function color(a){
                        if ( !jQuery.browser.safari )
                                return false;

                        var ret = document.defaultView.getComputedStyle(a,null);
                        return !ret || ret.getPropertyValue("color") == "";
                }

                if (prop == "opacity" && jQuery.browser.msie) {
                        ret = jQuery.attr(elem.style, "opacity");
                        return ret == "" ? "1" : ret;
                }

                if (prop.match(/float/i))
                        prop = styleFloat;

                if (!force && elem.style[prop])
                        ret = elem.style[prop];

                else if (document.defaultView &&
document.defaultView.getComputedStyle) {

                        if (prop.match(/float/i))
                                prop = "float";

                        prop = prop.replace(/([A-Z])/g,"-$1").toLowerCase();
                        var cur = document.defaultView.getComputedStyle(elem, 
null);

                        if ( cur && !color(elem) )
                                ret = cur.getPropertyValue(prop);

                        // If the element isn't reporting its values properly 
in Safari
                        // then some display: none elements are involved
                        else {
                                // Locate all of the parent display: none 
elements
                                for ( var a = elem; a && color(a); a = 
a.parentNode )
                                        stack.unshift(a);

                                // Go through and make them visible, but in 
reverse
                                // (It would be better if we knew the exact 
display type that they
had)
                                for ( a = 0; a < stack.length; a++ )
                                        if ( color(stack[a]) ) {
                                                swap[a] = 
stack[a].style.display;
                                                stack[a].style.display = 
"block";
                                        }

                                // Since we flip the display style, we have to 
handle that
                                // one special, otherwise get the value

//bug fix - http://dev.jquery.com/ticket/1661
//                              ret = prop == "display" && swap[stack.length-1] 
!= null ?
//                                      "none" :
//
document.defaultView.getComputedStyle(elem,null).getPropertyValue(prop)
|| "";

                                ret = (prop == "display" && 
swap[stack.length-1] != null) ?
                                        "none" :
                                        
(document.defaultView.getComputedStyle(elem,null) != null) ?
        
document.defaultView.getComputedStyle(elem,null).getPropertyValue(prop) :
"";



                                // Finally, revert the display styles back
                                for ( a = 0; a < swap.length; a++ )
                                        if ( swap[a] != null )
                                                stack[a].style.display = 
swap[a];
                        }

                        if ( prop == "opacity" && ret == "" )
                                ret = "1";

                } else if (elem.currentStyle) {
                        var newProp = 
prop.replace(/\-(\w)/g,function(m,c){return
c.toUpperCase();});
                        ret = elem.currentStyle[prop] || 
elem.currentStyle[newProp];

                        // From the awesome hack by Dean Edwards
                        // 
http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291

                        // If we're not dealing with a regular pixel number
                        // but a number that has a weird ending, we need to 
convert it to
pixels
                        if ( !/^\d+(px)?$/i.test(ret) && /^\d/.test(ret) ) {
                                var style = elem.style.left;
                                var runtimeStyle = elem.runtimeStyle.left;
                                elem.runtimeStyle.left = elem.currentStyle.left;
                                elem.style.left = ret || 0;
                                ret = elem.style.pixelLeft + "px";
                                elem.style.left = style;
                                elem.runtimeStyle.left = runtimeStyle;
                        }
                }

                return ret;
        }
});


Reply via email to