iframe adjust size code example

Example 1: set iframe height and width

#IFRAME_ID {
  width: 100%!important;
  height: 100%!important;
}
<iframe src="http://www.youraddress.com" id="IFRAME_ID"></iframe>

Example 2: making iframe fit the content size

var frame = document.getElementById("Iframe");
          
        // Adjusting the iframe height onload event
        frame.onload = function()
        // function execute while load the iframe
        {
          // set the height of the iframe as 
          // the height of the iframe content
          frame.style.height = 
          frame.contentWindow.document.body.scrollHeight + 'px';
           
  
         // set the width of the iframe as the 
         // width of the iframe content
         frame.style.width  = 
          frame.contentWindow.document.body.scrollWidth+'px';

Tags:

Misc Example