Answers for "how to fit iframe in a page"

0

how to show iframe in full width

<div>
  <div style="position:relative;padding-top:56.25%;">
    <iframe src="https://www.youtube.com/embed/nckseQJ1Nlg" frameborder="0" allowfullscreen
      style="position:absolute;top:0;left:0;width:100%;height:100%;"></iframe>
  </div>
</div>
Posted by: Guest on May-22-2021
0

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';
Posted by: Guest on May-10-2021

Browse Popular Code Answers by Language