Foros del Web » Programando para Internet » Javascript »

nada nuevo en IE NO FUNCIONA

Estas en el tema de nada nuevo en IE NO FUNCIONA en el foro de Javascript en Foros del Web. Como siempre tengo un codigo que en FF funciona correctamente y en IE, no se por que,no. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> ...
  #1 (permalink)  
Antiguo 30/05/2008, 11:31
 
Fecha de Ingreso: febrero-2007
Mensajes: 103
Antigüedad: 17 años, 2 meses
Puntos: 0
nada nuevo en IE NO FUNCIONA

Como siempre tengo un codigo que en FF funciona correctamente y
en IE, no se por que,no.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sin t&iacute;tulo</title>
<style type="text/css">
<!--
#myId {
height: 200px;
width: 400px;
border-top-width: 3px;
border-right-width: 3px;
border-bottom-width: 3px;
border-left-width: 3px;
border-top-style: solid;
border-right-style: solid;
border-bottom-style: solid;
border-left-style: solid;

}
-->
</style>
</head>

<body>

<script type="text/javascript">
var p=document.createElement("p");
p.setAttribute("style","color:red");
div=document.createElement("div");
div.setAttribute("id","myId");
//div.setAttribute("style","visibility:visible");
var texto=document.createTextNode("Este texto es para agregar al parrafo");

p.appendChild(texto);

document.body.appendChild(div).appendChild(p);

function ocultar(){
div.setAttribute("style","visibility:hidden");

}

function mostrar(){
div.setAttribute("style","visibility:visible");

}


</script>

<form >
<input name="" type="button" onclick="javascript:ocultar();" value="ocultar" />
<input name="" type="button" onclick="javascript:mostrar();" value="mostrar" />
</form>

</body>
</html>



El codigo es parte de un ejercicio y lo que hace es ocultar un div o presentarlo cuando se pulsa un boton u otro
  #2 (permalink)  
Antiguo 31/05/2008, 04:52
Avatar de 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: nada nuevo en IE NO FUNCIONA

Fijate así:
Código PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html xmlns="http://www.w3.org/1999/xhtml">
<
head>
<
meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<
title>Documento sin t&iacute;tulo</title>
<
style type="text/css">
<!--
#myId {
height200px;
width400px;
border-top-width3px;
border-right-width3px;
border-bottom-width3px;
border-left-width3px;
border-top-stylesolid;
border-right-stylesolid;
border-bottom-stylesolid;
border-left-stylesolid;

}
-->
</
style>
</
head>

<
body>

<
script type="text/javascript">
var 
p=document.createElement("p");
//p.setAttribute("style","color:red");
p.style.color='red';
div=document.createElement("div");
//div.setAttribute("id","myId");
div.id="myId";
var 
texto=document.createTextNode("Este texto es para agregar al parrafo");

p.appendChild(texto);

document.body.appendChild(div).appendChild(p);

function 
ocultar(){
//div.setAttribute("style","visibility:hidden");
div.style.visibility='hidden';
}

function 
mostrar(){
//div.setAttribute("style","visibility:visible");
div.style.visibility='visible';
}


</script>

<form >
<input name="" type="button" onclick="ocultar();" value="ocultar" />
<input name="" type="button" onclick="mostrar();" value="mostrar" />
</form>

</body>
</html> 
Comenté el código a modificar. Los atributos normales no es necesario declararlos con setAttribute. Las llamadas a la funciónes javascript, a menos que la escribas como href de enlaces o las escribas en la barra de direcciones del navegador para hacer algun testeo, no necesitan el "javascript:".
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 04:15.