Automatic Resizing iframe problems with Google Chrome

barnettcanary

New Member
I have a website that I have created with css and divs. The problem I ran into was originally with the menu and not wanting to change it on every page when something new needed to be added to the menu. After a lot of trying and failing at many different approaches, I decided for now just to add an iframe in an enclosed div, and automatically set the height to grab the content so the main template as such doesn't need to be changed.After playing around with it, I managed to get it working on all browsers (ie, ff, safari, opera) except for chrome.The javascript I'm using is:\[code\] <script type="text/javascript"> function calcHeight() { //find the height of the internal page var the_height= document.getElementById('the_iframe').contentWindow. document.body.scrollHeight; //change the height of the iframe document.getElementById('the_iframe').height= the_height; } </script>\[/code\]With the code for the iframe being:\[code\]<iframe width="960px" src="http://stackoverflow.com/questions/15888822/testytest.htm" id="the_iframe" onLoad="calcHeight();" height="1px" frameborder="0" scrolling="no"></iframe>\[/code\]This has been the easiest solution to be able to change the content in the main page by using the menu bar so far, except for it not appearing properly in Chrome. Any help would be greatly appreciated! Thanks!
 
Top