If you've given the <iframe>
element an ID then document.getElementById()
will work. If you're trying to get hold of its window
object then you'll need to use the iframe element's contentWindow
property (or use the more standard contentDocument
, which is a reference to the iframe's document
object but is sadly absent from IE, at least up to and including version 7):
var iframe = document.getElementById("your_iframe_id");
var iframeWin, iframeDoc;
if (iframe.contentDocument) {
iframeDoc = iframe.contentDocument;
iframeWin = iframeDoc.defaultView;
} else if (iframe.contentWindow) {
iframeWin = iframe.contentWindow;
iframeDoc = iframeWin.document;
}