Possible Duplicate:
Iframe Function Calling From Iframe to parent page javascript function
I need to run a JavaScript function (in an HTML page) from an iframe, I followed the instructions I found online but I couldn't make it work. Any ideas?
Here's the code:
<html>
<head>
<script type="text/javascript">
function testFunction()
{
var jsmessage = "Test succeed.";
alert(jsmessage);
return false;
}
</script>
</head>
<body>
<iframe id="myframe" src="iframe.html" height="260" width="620" frameborder="0"></iframe>
</body>
</html>
And here's the iframe.html code:
<html>
<body>
<input type="button" onclick="parent.testFunction();" value="Test function">
</body>
</html>