JavaScript Program for Calling child window JS function in Frame

Write a JavaScript program for calling child window js function in frame.



Source Code
<html>
<head>
    <title>Calling child window JS function</title>
</head>
<frameset rows="*, *">
    <frame src="webpage1.html" name="topPage"/>
    <frame src="webpage2.html" name="bottomPage"/>
</frameset>
</html>


<html>
<head>
    <title>Webpage 1</title>
    <script>
        function changeMe()
        {
            document.getElementById('panel').innerHTML = 'I am called from webpage2'
        }
    </script>
</head>
<body>
<input type="button" value="Webpage 1" />
<p id="panel"></p>
</body>
</html>


<html>
<head>
    <title>Webpage 2</title>
</head>
<body>
<input type="button" value="Webpage 2" onclick="parent.topPage.changeMe()" name="btn"/>
</body>
</html>
Output