Jump to content

[SOLVED] access innerhtml property of div in a child window?


monkotronic

Recommended Posts

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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.