
September 1st, 2011, 01:35 PM
|
|
Contributing User
|
|
Join Date: Nov 2008
Posts: 44
  
Time spent in forums: 20 h 21 m 3 sec
Reputation Power: 6
|
|
|
Issue With Setting DIV Height Based Upon Iframe Height In Chrome
I cannot get the iframe height in chrome, but I can get it in IE & FF. Can someone tell me where the issue is at in my code?
Code:
<script type="text/javascript">
function getContent()
{
// IE & FF
var frame_height_one = document.getElementById("my_iframe").contentWindow.document.body.scrollHeight;
document.getElementById("content_viewer").style.height = frame_height_one;
// Chrome & Safari
var frame_height_two = document.getElementById("my_iframe").contentDocument.document.body.scrollHeight;
document.getElementById("content_viewer").style.height = frame_height_two;
}
window.onload = function() {
getContent();
}
</script>
<div id="content_viewer">
<iframe id="my_iframe" src="iframe_page.html" width="100%" height="100%"></iframe>
</div>
I also tried this, but it didn't work either:
Code:
var frame_height_two = document.getElementById("my_iframe").contentDocument.body.scrollHeight;
|