In my web project, there are two HTML files - one is named main.html
and the other is called child.html
. The main.html
file contains an iframe
element with the id of "myFrame" that displays the content of the child.html
page. Both pages have a button labeled "Hide frame". When this button is clicked, it triggers the hideFrame()
JavaScript function which can be found in the main.js
file. This function simply changes the display property of the myFrame
element to "none".
function hideFrame(){
document.getElementById("myFrame").style.display = "none";
}
When the button within the main.html
file is clicked, the hideFrame()
function works as intended and hides the frame. However, trying to call the same function from the child.html
page does not work.
The challenge now is figuring out how to access the myFrame
element from the child.html
page.