Ver Mensaje Individual
  #1 (permalink)  
Antiguo 04/05/2006, 09:28
matrixer
 
Fecha de Ingreso: mayo-2006
Mensajes: 3
Antigüedad: 18 años, 10 meses
Puntos: 0
Pregunta FireFox e IExplorer: ¿Jerarquías con implementaciones diferentes?

consideren el siguiente código:


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin t&iacute;tulo</title>
<script language="javascript1.3">
function estiraEncoje()
{
obj = document.forma.texto;
if(obj.size>10)
{
obj.size=10;
}
else
{
obj.size=20;
}

}
function genera()
{
var newE = document.createElement('input');
newE.type = "button";
newE.name = "bt";
newE.value = "tocame";
newE.onclick = estiraEncoje;
document.forma.appendChild(newE);
}
function destruye()
{
buttons = document.forma.childNodes;
if (buttons.length>1)
{
toDelete = buttons[1];
document.forma.removeChild(toDelete);
}
}
function imprime()
{
childs = document.forma.childNodes;
texto = "";
for(i=0; i<childs.length; i++)
{
texto = texto + " " + childs[i].nodeType;
}
document.write(texto);
}
</script>
</head>

<body>
<input type="button" name="genera" onclick="genera()" value="generador">
<input type="button" name="destruye" onclick="destruye()" value="destructor">
<input type="button" name="imprime" onclick="imprime()" value="impreime hijos de forma">

<form name="forma" >
<input type="text" name="texto" value="como que no?" onclick="estiraEncoje(document.getElementById('tex to'));"></form>
</body>
</html>


Este código funciona de manera diferente en Firefox que en IE. Una vez pulsado el boton "generador" se crea un nuevo botón "tocame". Pero al pulsar "destructor" Firefox borra el input mientras IE borra el botón tócame. ¿Acaso la jerarquía de nodos no es la misma en ambos navegadores?¿Qué diferencia es la qué provoca el cambio en el comportamiento?