Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

child window getelementbyid



10:12 am on Dec 13, 2009 (gmt 0)

5+ Year Member

Probably a dumb question but my limited js skills have failed! Any help appreciated ...

An html page, the parent, creates a child page into which is loaded a new url using window.open() from the parent page. I now need to getelementbyid() of an id from the child page into a variable in the parents js code. Something like:

settimeout(wait for child to load fully);
alert (childidvalue);


12:27 pm on Dec 13, 2009 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member

var childHandle; // this needs to be global
childHandle = window.open(url,childwindow);
function checkLoaded() {
var el = childHandle.document.getElementById("idinchild"); // case matters
if ( el ) { alert( el.innerHTML ); }
else { settimeout( checkLoaded ... ); } // assume not loaded yet, try later

Note that url must be same domain as parent page, security limitation.


10:55 pm on Dec 13, 2009 (gmt 0)

5+ Year Member

Thanks daveVk, appreciated.

Featured Threads

Hot Threads This Week

Hot Threads This Month