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';
          

Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
scale iframe content to fit screen iframe resize to fit content change iframe content size how to fit iframe in a page how to make iframe fit on box how to make iframe fit content iframe scale content to fit Iframe size to fit scale iframe content to fit change iframe height to fit content iframe to fit div iframe content fit iframe size html iframe fit content how to make content fit iframe iframe content scale how to fit content in iframe iframe auto resize to fit contents iframe to fit with content make iframe scale to size of content css text iframe full width shrink iframe content to fit iframe fit to content iframe height fit content css how to scale iframe content size iframe to fit content resize iframe to size of content html iframe size to fit iframe to fit to div and be responsive expand iframe to fit content javascript set iframe fit content iframe content size make iframe fit div change iframe size based on content resize iframe to fit content fit html page to iframe size scale content to fit iframe scale content of iframe resize content to fit iframe iframe image size fit iframe size to fit content iframe adjust size make iframe full size of container iframe height to fit content iframe width according to the content how to scale the content of iframe iframe expand to fit content automatically resize content to fit iframe adapt iframe width to content iframe width fit content iframe width fit to screen how to expand iframe to fit content how to fit content on iframe make iframe fit content iframe height fit content iframe fit to width iframe fit content making iframe fit the content size
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source