Wednesday, April 15, 2009

Calling javscript method in different frames.

Step1:

Create one html page with following frames with frameset.

<frameset cols="30%,70%">
<frame src="testFrame.aspx" name="foody"/>
<frame src="Frame1.aspx" name="goody"/>
</frameset>

step 2:

Create one javascript method in testFrame.aspx, which it has been included in frame 1.

Javascript method.

function getValueFrame1()
{
alert("hi");
}

step 3:

call that javacript method in the second frame of page.

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>

</div>
</form>
<script language="javascript">
parent.foody.getValue();
</script>
</body>
</html>

Note:foody is frame name