There’s an easier way that’s been around longer… use window.frames
to get a reference to the frame’s window object.
By name or id:
var iframe_doc = window.frames.my_iframe.document;
or if you prefer:
var iframe_doc = window.frames['my_iframe'].document;
or by index:
var iframe_doc = window.frames[0].document;
Good reference for window.frames
here: http://developer.mozilla.org/en/DOM/window.frames
An excerpt:
each item in the window.frames
pseudo-array represents the window
object corresponding to the given
<frame>’s or <iframe>’s content, not
the (i)frame DOM element (i.e.
window.frames[ 0 ] is the same thing
as document.getElementsByTagName(
“iframe” )[ 0 ].contentWindow)