Tema: error con if
Ver Mensaje Individual
  #2 (permalink)  
Antiguo 20/12/2010, 11:49
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: error con if

Habría que ver cómo establecés el estilo display. Tal como lo estás intentando leer sólo obtendrás resultados si lo has asignado vía javascript o con el atributo html style colocado en el mismo tag del elemento. Si lo has asignado mediante una hoja de estilos o mediante un tag <style> no te funcionará. Para que funcione en esos casos hay que leer los estilos computados por el navegador mediante una función como esta:
Código:
function css(id,prop){
    if(window.getComputedStyle){
        return document.defaultView.getComputedStyle(document.getElementById(id),null).getPropertyValue(prop);
    }else{
        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 document.getElementById(id).currentStyle[prop] ? document.getElementById(id).currentStyle[prop] : null;
    }
}