OiO.lk Blog HTML How do I make a iframe adjust to the height of the content when the content is a PDF?
HTML

How do I make a iframe adjust to the height of the content when the content is a PDF?


I have a iframe,but I want to integrate it into the website with no scroll bar, so the size should be the size of the content.

There are many questions about IFrames and making their size equal to their content’s size, but none of the solutions to those questions seem to work in my case.
I tried using
View.js

function resizeIframe(frame) {
    frame.style.height = frame.contentWindow.document.body.scrollHeight + 'px'
}

View.html

        <iframe src="{{source}}" onload="resizeIframe(this)">

        </iframe>

But, all of my content is in PDF files, and frame.contentWindow.document.body.scrollHeight is 0.
How do I do this?



You need to sign in to view this answers

Exit mobile version