
17/10/2011, 10:50
|
| | Fecha de Ingreso: agosto-2011
Mensajes: 78
Antigüedad: 13 años, 7 meses Puntos: 1 | |
Acceder a un elemento del Iframe Hola a todos. tengo un problema al querer acceder a un elemento del iframe.
<html>
<head>
<title>IFrames dinámicos</title>
<script language="javascript">
function modiframe()
{
var pepe =document.getElementById('pepe').value;
frames.marco.location=pepe;
}
function aver()
{
var hola= frames.marco.document.getElementById('name1').valu e;
alert(hola);
}
</script>
</head>
<body>
<iframe id="marco" width="300" height="400" src="hola.html" ></iframe>
Para cambiar iframe:<INPUT id= "pepe" TYPE="text" NAME="pepe"><BR>
<INPUT TYPE="submit" VALUE="Aparecer" onclick= "javascript:modiframe()";>
<INPUT TYPE="submit" VALUE="Ver" onclick= "javascript:aver()";>
</FORM>
</body>
</html>
Yo tengo un archivo hola.html, que tiene un <a id="name1">. yo lo seteo y me muestra en el iframe esta pagina. luego cuando hago click en el boton Ver que ejecuta el metodo aver(); me sale un error:
Uncaught TypeError: Cannot call method 'getElementById' of undefined.
El problema es cuando quiero hacer esto: frames.marco.document.getElementById('name1').valu e;
Probe sacando getElementById('name1').value y me imprime el alert con valor UNDEFINED.
Que puede ser? gracias!
__________________ Gimnasia y esgrima de la plata |