Reputation: 87
I'm using frame and frameset for my page. To access an element in a frame from another frame, I used this js code:
parent.frames['frame1'].document.getElementById('inputfield1');
But it just works well with Webkit. It's failed on Firefox. I think my code is wrong. How could I make it work on Firefox ?
<frameset id="fset" rows="60%,40%" frameborder="1">
<frame name="frame1" src="...">
<frame name="frame2" src="...">
</frameset>
Upvotes: 1
Views: 1499
Reputation: 966
Insert the following into head section of your main page.
<script language="javascript" type="text/javascript">
function doSomething() {
var iframe = document.getElementById('frame1');
var innerDoc = iframe.contentDocument || iframe.contentWindow.document;
var your_input_field = innerDoc.getElementById(inputfield1);
}
</script>
You can then use parent.doSomething();
inside the frames to call doSomething() of main page which can reach both frames.
Upvotes: 1