Ver Mensaje Individual
  #5 (permalink)  
Antiguo 17/11/2009, 20:17
Avatar de caneva
caneva
 
Fecha de Ingreso: junio-2006
Ubicación: Sevilla (España)
Mensajes: 81
Antigüedad: 18 años, 8 meses
Puntos: 1
Respuesta: Sencillo pero raro, redefinir ancho y alto

Cita:
Iniciado por zerokilled Ver Mensaje
¿como estas rellenando el DIV? ¿con ajax? si es asi, ¿en que momento invocas la funcion que crea la ventana?
Código PHP:
function recolocar_ventana()
{
    var 
ventana document.getElementById("contenido");
    var 
anchofinal ventana.offsetWidth;
    var 
altofinal ventana.offsetHeight;
    
alert("Anchofinal: "+anchofinal+", Altofinal: "+altofinal);
    
ventana.style.marginLeft "-"+ (anchofinal/2) + "px";
    
ventana.style.marginTop "-" + (altofinal/2) + "px";
}

function 
crear_ventana(nombreanchoaltoreferenciaseccion)
{
    var 
anterior document.getElementById(nombre);
    if ( !
anterior //Si no existe ya esa ventana creala. 
    
{
        var 
divprincipal document.createElement("div"); //Creamos un elemento div
        
divprincipal.setAttribute("id"nombre); //Le asignamos como Id el parámetro nombre.
        
divprincipal.style.visibility "visible";
        
        
//Creamos sus dos divs hijos.
        
var hijoprincipal document.createElement("div");
        
divprincipal.appendChild(hijoprincipal);
        
hijoprincipal.setAttribute("id""fondo");
        
//Atributos de estilo CSS:
        
hijoprincipal.style.position "absolute";
        
hijoprincipal.style.backgroundColor "#CCCCCC";
        
hijoprincipal.style.opacity "0.5";
        
hijoprincipal.style.filter "alpha(opacity=50)";
        
hijoprincipal.style.height "100%";
        
hijoprincipal.style.width "100%";    
        
hijoprincipal.style.top "0";
        
hijoprincipal.style.left "0";
        
hijoprincipal.style.zIndex "1";
        
        var 
hijosecundario document.createElement("div");
        
divprincipal.appendChild(hijosecundario);
        
hijosecundario.setAttribute("id""contenido");
        
//Atributos de estilo CSS:
        
hijosecundario.style.position "absolute";
        
hijosecundario.style.backgroundColor "#FFFFFF";;
        
hijosecundario.style.top "50%";
        
hijosecundario.style.left "50%";
        
hijosecundario.style.zIndex "2";
        
hijosecundario.style.padding "25px";
        
        
xhr getHTTPObject();
        
xhr.onreadystatechange = function(){
        if(
this.readyState != 4)return;
        
hijosecundario.innerHTML this.responseText//hijosecundario es el objeto DOM que contendrá lo que se cargue en la petición ajax
        
}
        
xhr.open('get''http://www.midominio.com/objetos/formularios/'nombre +'.php?sec='secciontrue); //Cargar el contenido de la ventana
        
xhr.send(null);
        
//Colocamos el divprincipal con sus hijos en el punto de referencia del html o "ancla".        
var ancla document.getElementById(referencia);
        
ancla.appendChild(divprincipal);
        
        
recolocar_ventana(); //Reposicionamos la "ventana"
    
}
    else
    { 
abrir_ventana(nombre); }

Por cierto el error no ocurre en IE, si en FF y Chrome.
__________________
Cita:
"El camino empieza renunciando al control, y volviéndose flexibles."

Última edición por caneva; 17/11/2009 a las 21:08