Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Merging two Frames

Status
Not open for further replies.

hjuan99

Programmer
May 12, 2003
4
US
I have created two frames for a webpage. Is there any way I can merge them together? ie. I have one frame on top and one frame on the bottom and I want to end up with no frames, just the html from the top frame with the html from the bottom frame directly underneath it merged together.

Thanks,
John
 
Sort of. If you have some hidden <iframes> down the bottom of your page, you can use javascript to reach in and grab the HTML out of each iframe and insert it into a <div> tag.

Try something like this and see if it's what you're after:
[tt]<html>
<head>
<script>
function populate(){
var htmlmerge = '';
for(x=0; x < window.frames.length; x++) {
//alert(document.getElementById(document.frames[x].name).contentWindow.document.body.scrollHeight);
htmlmerge = htmlmerge + document.getElementById(document.frames[x].name).contentWindow.document.body.innerHTML;
}
document.all.content.innerHTML = htmlmerge;
}
</script>
</head>
<body onLoad=&quot;populate()&quot;>
<div id=&quot;content&quot;>
</div>
<div style=&quot;visibility:hidden&quot;>
<iframe name=&quot;frame1&quot; id=&quot;frame1&quot; src=&quot;frame1.html&quot;></iframe>
<iframe name=&quot;frame2&quot; id=&quot;frame2&quot; src=&quot;frame2.html&quot;></iframe>
</div>
</body>
</html>[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top