1

I am unable to adjust auto height according to the page content.

Code -

<iframe width="100%" id="myFrame" src="http://www.learnphp.in" scrolling="no">
</iframe>

I prefer Make iframe automatically adjust height according to the contents without using scrollbar? but this code doesn't work. Please suggest me how to get complete data without using scroll?

Community
  • 1
  • 1
Developer
  • 2,676
  • 8
  • 43
  • 65
  • please refer this. similar one http://stackoverflow.com/questions/9162933/make-iframe-height-dynamic-based-on-content-inside-jquery-javascript – chandu Apr 26 '14 at 10:22
  • @chandu Yes it it working for same domain. How it will work cross domain? – Developer Apr 26 '14 at 11:33

1 Answers1

0

Try this

<script>   
function autoResize(myiframe){
    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(myiframe).height= (newheight) + "px";
    document.getElementById(myiframe).width= (newwidth) + "px";
}
</script>

<body>  
 <div align="center" style="padding-left:50px">
      <iframe id="myiframe" src="helpdesk/index.php" width="800"></iframe>
 </div>
</body>
Developer
  • 2,676
  • 8
  • 43
  • 65