Access child iFrame DOM from parent page

There is a way. When the page in the iframe loads, have it do the following

parent.childGetElementById = function (id) {return document.getElementById(id);}
parent.childLoaded();

This will make a function in the global scope of the parent page (that contains the iframe). Then in the parent, just have the following

function childLoaded() {var dom = childGetElementById('someid');}

This is along as you have control of the page your loading into the iframe… if you do not, you are out of luck.

Leave a Comment