JavaScript Program for Calling Function from Another Frame

Write a JavaScript program for calling function from another frame .



Source Code
<html>
<head>
    <title>Call Child Window Frame Example</title>
</head>
<frameset rows="*, *">
    <frame src="webpage1.html" name="topPage"/>
    <frame src="webpage2.html" name="bottomPage"/>
</frameset>
</html>


<html>
<head>
    <title>Web page 1</title>
    <script>
        function changeContent()
        {
            document.getElementById('label1').innerHTML = "Function called from webpage2"
        }
    </script>
</head>
<body>
<input type="button" name="WebPage1" value="Web Page 1"/>
<label id="label1"></label>
</body>
</html>


<html>
<head>
    <title>Web page 2</title>
</head>
<body>
<input type="button" name="WebPage2" value="Web Page 2" onclick="parent.topPage.changeContent()"/>
</body>
</html>
Output