Foros del Web » Programando para Internet » Javascript »

Como hacerlo en mozilla

Estas en el tema de Como hacerlo en mozilla en el foro de Javascript en Foros del Web. Hola tengo esta sentencia: posicion = document.body.clientWidth/2 - capa.offsetWidth/2; Que funciona para explorer y no para mozilla. Alguna ayuda? Saludos Jaime...
  #1 (permalink)  
Antiguo 30/03/2006, 10:03
 
Fecha de Ingreso: noviembre-2005
Mensajes: 405
Antigüedad: 18 años, 5 meses
Puntos: 0
Como hacerlo en mozilla

Hola tengo esta sentencia:
posicion = document.body.clientWidth/2 - capa.offsetWidth/2;

Que funciona para explorer y no para mozilla.

Alguna ayuda?
Saludos
Jaime
  #2 (permalink)  
Antiguo 30/03/2006, 10:13
Avatar de JavierB
Colaborador
 
Fecha de Ingreso: febrero-2002
Ubicación: Madrid
Mensajes: 25.052
Antigüedad: 22 años, 2 meses
Puntos: 772
Hola infolan

Prueba poniendo un id a la capa: <div id="capa">

y usando este código:

posicion = document.body.clientWidth/2 - document.getElementById('capa').offsetWidth/2;

Saludos,
  #3 (permalink)  
Antiguo 30/03/2006, 10:23
 
Fecha de Ingreso: noviembre-2005
Mensajes: 405
Antigüedad: 18 años, 5 meses
Puntos: 0
El fallo lo tengo antes de esa sentencia te paso todo el codigo a ver que puedes encontrar:

function GetInput(doc, Input)
{
var e;
e=GetObj(doc, Input);
return (e?e.value:'');
}

function GetObj(doc, Input)
{
return GetBase(doc,Input);
}

function GetBase(doc, Input)
{

if (doc.getElementById)
{
return doc.getElementById(Input);

}
else if (doc.all)
{
return doc.all[Input];
}
else if (doc.layers)
{
return doc.layers[Input];
}
}

function SetInput(doc, Input, Value)
{
var e;
e=GetObj(doc, Input);
if (e!=null)
{
e.value=Value;
}
}

function SetLabel(doc, Input, Value)
{
var e;
e=GetObj(doc, Input);
if (e!=null)
{
e.innerText=Value;
}
}

function activarObservaciones(nominput, descripcion)
{
var editando;
var capa
capa=document.getElementById('capaObservaciones');
editando=GetInput(document, "nameInputHiddenTextArea");
if (editando!="")
{
alert("Per a editar aquest camp hauria de tancar abans la pantalla d'edici? activa");
return;
}

SetInput(document, "nameInputHiddenTextArea" , nominput);
SetLabel(document, "textLabel" , descripcion);

var valor=GetInput(document, nominput);
document.getElementById('capaObservaciones').style .visibility = 'visible';
document.getElementById('nameTextArea').value=valo r;


//Posicionar la capa en el centre de la finestra.
posicion = document.body.clientWidth/2 - capa.offsetWidth/2;

posicionh = (document.body.clientHeight/2+document.body.scrollTop) - capa.offsetHeight/2;
capa.style.left = posicion;
capa.style.top = posicionh;

//Creem un "iframe", per ocultar els "combos", sino ho fem, els "combos" es mostraria per davant de la capa.
var name;
name = "iFrameObservaciones";
crearIframe(capa.offsetLeft,capa.offsetTop,capa.of fsetWidth,capa.offsetHeight,name)
}

function crearIframe(left,top,width,height,name)
{
iframMenu = document.createElement("iframe");
iframMenu.setAttribute("src", "javascript:false;");
iframMenu.setAttribute("frameborder",1);
iframMenu.setAttribute("scrolling", "no");
iframMenu.setAttribute("id", name);
iframMenu.style.width = width;
iframMenu.style.height = height;
iframMenu.style.top = top;
iframMenu.style.left = left;
iframMenu.style.position = "absolute";
iframMenu.style.display = "block";
iframMenu.zIndex = 100;
document.body.appendChild(iframMenu);
return iframMenu;
}

function eliminarIframe(name)
{
var iframeRemove = document.getElementById(name);
document.body.removeChild(iframeRemove);
}

function tancarCapa()
{
var nominput;
var valors;
var capa;

capa=document.getElementById('capaObservaciones');
nominput=GetInput(document, "nameInputHiddenTextArea");

if (nominput=="")
{
alert("Error... No s'est? editant");
return;
}

valors=GetInput(document,"nameTextArea");
document.getElementById(nominput).value=valors;

// Netegem
SetInput(document, "nameInputHiddenTextArea", "");
SetLabel(document, "textLabel", "");
SetInput(document, "nameTextArea", "");
capa.style.position = 'absolute';
capa.style.visibility = 'hidden';

// Esborrem el "iframe" que usem per a ocultar els "combos".
var name;
name = "iFrameObservaciones";
eliminarIframe(name);
}

function removeFocus(currentObject)
{
currentObject.className='input_grid_focus';
}

function setFocus(currentObject)
{
currentObject.className='input_grid_removefocus';
}

function anyadir()
{
obj=document.getElementById('strutsAccion');
val=obj.value;
if (obj.selectedIndex < 0)
{
return;
}
txt=obj.options[obj.selectedIndex].text;
var selOpcion=new Option(txt, val);
iPos=document.getElementById('grups').options.leng th;
eval(document.getElementById('grups').options[iPos]=selOpcion);
document.getElementById('strutsAccion').options[obj.selectedIndex]=null;
}

function quitar()
{
obj=document.getElementById('grups');
val=obj.value;
if (obj.selectedIndex < 0)
{
return;
}
txt=obj.options[obj.selectedIndex].text;
var selOpcion=new Option(txt, val);
iPos=document.getElementById('strutsAccion').optio ns.length;
eval(document.getElementById('strutsAccion').optio ns[iPos]=selOpcion);
document.getElementById('grups').options[obj.selectedIndex]=null;
}

function activateInput(obj,input)
{
if (document.getElementById(obj).checked==true)
{
document.getElementById(input).disabled=false;
}
else
{
document.getElementById(input).disabled=true;
}
}
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 11:08.