Christian Heinrichs Christian Heinrichs - 2 months ago 10
CSS Question

Accessing HTML elements inside frames from parent document

How can I access HTML elements contained in a frame from the parent document?

I have tried window.frames, contentWindow and parent.frames, but I get all kinds of errors.

Here is the code of the parent HTML file:

<title>Parent HTML file</title>
<script type="text/javascript">
<frameset cols="50%,50%">
<frame src="frame1.html" name="frame1">
<frame src="frame2.html" name="frame2">


frames collection or any inputs don't exist at the time you try to refer them. You can try this:

window.onload = function () {

Notice, that frames collection contains window objects instead of frame/iframe elements.