Welcome to WebmasterWorld Guest from 54.162.240.235

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:

parent
------
window.open(url,childwindow);
settimeout(wait for child to load fully);
childidvalue=childwindow.document.getelementbyid("idinchild").innerhtml;
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);
checkLoaded();
...
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