Tengo un problema al llamar a una función de JavaScript en un iframe
desde la página principal. Aquí es mis dos páginas:Llamar a la función javascript en iframe
mainPage.html
<html>
<head>
<title>MainPage</title>
<script type="text/javascript">
function Reset()
{
if (document.all.resultFrame)
alert("resultFrame found");
else
alert("resultFrame NOT found");
if (typeof (document.all.resultFrame.Reset) == "function")
document.all.resultFrame.Reset();
else
alert("resultFrame.Reset NOT found");
}
</script>
</head>
<body>
MainPage<br>
<input type="button" onclick="Reset()" value="Reset"><br><br>
<iframe height="100" id="resultFrame" src="resultFrame.html"></iframe>
</body>
</html>
resultFrame.html
<html>
<head>
<title>ResultPage</title>
<script type="text/javascript">
function Reset()
{
alert("reset (in resultframe)");
}
</script>
</head>
<body>
ResultPage
</body>
</html>
(Sé que document.all
no es recomendable, pero esta página sólo debe ser visto con IE internamente y no creo que ese sea el problema)
Cuando Presiono el botón Restablecer, obtengo "resultFrame found" y "resultFrame.Reset NOT found". Parece tener una referencia al marco pero no puede llamar a la función en el marco, ¿por qué?
duplicado de http://stackoverflow.com/questions/251420/invoking-javascript-in-iframe-from-parent-page –
Posible duplicado de [Invocar código JavaScript en un iframe de la página principal] (http://stackoverflow.com/questions/251420/invoking-javascript-code-in-an-iframe-from-the-parent-page) – luk3yx