Quantcast
Channel: Resizing an iframe based on content - Stack Overflow
Viewing all articles
Browse latest Browse all 28

Answer by Ahmy for Resizing an iframe based on content

$
0
0

If you do not need to handle iframe content from a different domain, try this code, it will solve the problem completely and it's simple:

<script language="JavaScript"><!--function autoResize(id){    var newheight;    var newwidth;    if(document.getElementById){        newheight=document.getElementById(id).contentWindow.document .body.scrollHeight;        newwidth=document.getElementById(id).contentWindow.document .body.scrollWidth;    }    document.getElementById(id).height= (newheight) +"px";    document.getElementById(id).width= (newwidth) +"px";}//--></script><iframe src="usagelogs/default.aspx" width="100%" height="200px" id="iframe1" marginheight="0" frameborder="0" onLoad="autoResize('iframe1');"></iframe>

Viewing all articles
Browse latest Browse all 28

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>