When you assign an element of a window to a variable with getElementById() or getElementByName(), that variable is referring to an Element Object that is a property of the Window Object. This behavior is not true for frames, however; the value of the name or ID of a frame element refer to a Window Object as opposed to an Element Object.
This means that you can treat that frame in your code as if it were its own Window Object using the Name or ID that you have assigned to that frame. I provide an example below.
The id fone given to this iframe Element does not refer to an Element Object, it refers to a Window Object.
<p style="color:blue" onClick="chngFrameStyle();">Click Me</p>
<iframe id="fone" src="OreillyCh14v2Iframe.html" width="50%" height="400px" ></iframe>
fone is treated as a Window Object. This Window Object has an Element Object with the id "iframewrap" that will be assigned a backgroundColor value of #444.
function chngFrameStyle() {
fone.document.getElementById("iframewrap").style.backgroundColor = "#444";
}