Ho problemi a chiamare una funzione JavaScript in un iframe
dalla pagina padre. Ecco i miei due pagine:Chiamata funzione javascript in 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>
(so che document.all
non è raccomandato, ma questa pagina devono essere utilizzate solo con IE internamente e non penso che sia il problema)
Quando Premendo il tasto Reset, ricevo "resultFrame found" e "resultFrame.Reset NON trovato". Sembra avere un riferimento al frame ma non può chiamare la funzione sul frame, perché è così?
duplicato di http://stackoverflow.com/questions/251420/invoking-javascript-in-iframe-from-parent-page –
Possibile duplicato di [Invocazione di codice JavaScript in un iframe dalla pagina padre] (http://stackoverflow.com/questions/251420/invoking-javascript-code-in-an-iframe-from-the-parent-page) – luk3yx