homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

child window getelementbyid

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

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)

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)

Thanks daveVk, appreciated.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved