I'm trying to resize an iframe according to height and width of it's content(webpage). I've used a code that I found on stack's other answer. For setup of new width, it seems that works but I can't get that height to work and I don't know why.
You can see and edit my example here: http://jsfiddle.net/dzorz/pvtr3/
Here is my HTML:
<iframe id="finance-iframe" class="finance-iframe" src="http://wordpress.org" width="100%" height="300px" marginheight="0" frameborder="0" onLoad="autoResize('finance-iframe');"></iframe>
and javascript:
function autoResize("finance-iframe"){
var newheight;
var newwidth;
if(document.getElementById){
newheight=document.getElementById("finance-iframe").contentWindow.document.body.scrollHeight;
newwidth=document.getElementById("finance-iframe").contentWindow.document.body.scrollWidth;
}
document.getElementById("finance-iframe").height= (newheight) + "px";
document.getElementById("finance-iframe").width= (newwidth) + "px";
}
What am I doing wrong?