monkotronic Posted July 9, 2007 Share Posted July 9, 2007 ok i opened a child window as such: theCart = window.open("whatever.html","theCart",cartFeatures); now i want to assign a div (id= "theDiv") some innerhtml: theCart.document.getElementById('theDiv').innerHTML = theTable; where theTable is some html code. it doesn't work. i get a "element has no properties" error. any ideas? websites? tutorials? code? for me??? the question in a general sense is: How do i reference the properties of an element in a child window? explicit code would be helpful since i have tried many variations already. thanks. Link to comment https://forums.phpfreaks.com/topic/59134-solved-access-innerhtml-property-of-div-in-a-child-window/ Share on other sites More sharing options...
nogray Posted July 9, 2007 Share Posted July 9, 2007 You gotta wait until the second page loads before you access it's elements. You can use the script inside the whatever.html page to get the code from the parent window once it loaded. in whatever.html <script language="javascript"> function ini_page(){ document.getElementById('theDiv').innerHTML = opener.getConent(); } </script> <body onload="ini_page();"> in the main page function getContent(){ return theTable; } Just make sure theTable is a global variable. Code untested. Link to comment https://forums.phpfreaks.com/topic/59134-solved-access-innerhtml-property-of-div-in-a-child-window/#findComment-293847 Share on other sites More sharing options...
monkotronic Posted July 10, 2007 Author Share Posted July 10, 2007 ;)it worked like a charm, thanks! Link to comment https://forums.phpfreaks.com/topic/59134-solved-access-innerhtml-property-of-div-in-a-child-window/#findComment-294379 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.