Ver Mensaje Individual
  #3 (permalink)  
Antiguo 10/07/2011, 16:38
Avatar de Panino5001
Panino5001
Me alejo de Omelas
 
Fecha de Ingreso: mayo-2004
Ubicación: -34.637167,-58.462984
Mensajes: 5.148
Antigüedad: 20 años
Puntos: 834
Respuesta: Acceder a elemento del estilo de un DIV

Una aclaración:
La siguiente sintaxis:
Código PHP:
referenciaElemento.style.propiedadCSS 
Es válida cuando el estilo es definido mediante el atributo style. Cuando es definido de otra manera hay que obtenerlo de los estilos computados:
Código PHP:
function getCSS(o,prop){
    if(
window.getComputedStyle){//STANDARD
        
return document.defaultView.getComputedStyle(o,null).getPropertyValue(prop); 
    }else{ 
//Explorer
        
var re = /(-([a-z]){1})/g
        if (
prop == 'float'prop 'styleFloat'
        if (
re.test(prop)) { 
            
prop prop.replace(re, function () { 
                return 
arguments[2].toUpperCase(); 
            }); 
        } 
        return 
o.currentStyle[prop] ? o.currentStyle[prop] : null
    } 
}  
//ejemplo de uso:
alert(getCSS(document.getElementById('pp'),'top'));