views:

249

answers:

1

so, I have 2 frames and want to access to element from one frame into another :

frame 1:

<div id='someId'>...</div>

frame 2:

var div=document.getElementById('someId');

div.innerHTML='something';

this is somehow not functioning in Firefox so I want to be sure, can I access to element in another frame by its ID ?

+1  A: 

You can refer the other frame by using

window.frames["framename"]

and then you can refer the element in the DOM by using

window.frames["framename"].document.getElementById ( "yourelementid" );
rahul
so, there is no option that browser would find first available element with desired ID no matter in which frame that reside ?
ante.sabo
@as: `getElementByid` is restricted to looking in the `document` object of which it is a method. Bear in mind that a frame is in fact a separate `window` object, and an examination of the `window`->`document` hierarchy should make it clear why a method on one `document` cannot examine a `document` in a different `window`.
NickFitz