In parent window, how to call a function definded in an iframe

Bookmark on del.icio.us

In parent window, how to call a In parent window, how to call a function definded in an <iframe>

For example, here is the parent window:

<html>

<iframe id=”sub_frame” src=”sub_frame.html”></iframe>

<script type=”text/javascript”><!–
test_function();
//–>
</script>
</html>

And this is sub_frame.html

<html>

<head>
<script type=”text/javascript”><!–
function sub_function()
{
alert(‘hello inside iframe‘);
}

//–>
</script>
</head>
</html>

And how to write test_function() to call sub_function from parent window?

I tried

function test_function()
{
//window.frames._frameNameOrId_.functionName()
window.frames.sub_frame.sub_function();
}
  1. No comments yet.

  1. No trackbacks yet.