Screen Doesn't Scroll To The End When Adding Iframe


I added an iframe inside the page and made it full size so it would scroll through the content when scrolling down, but the screen doesn’t scroll all the way.



it is because you have set scrolling="no" on iframe

If I remove it the problem goes away but the toolbar and other information don’t slide up when the iframe is scrolling.

this is how iframe works, to have it behave naturally you need to set its height equal to the height of containing window, which is not really possible to know if the website in iframe is not in same origin

1 Like

I receive emails from users, the result comes to me as HTML. So I hope I don’t get errors like same origin. When it is onLoad by giving useRef, I reached the width and height information by accessing the document object of the iframe. For now, it is what I wanted. I hope I don’t run into problems.

Mini demo:

const iframeRef = useRef(null);

const onViewerReady = () => {
  const mailBody = iframeRef.current.contentDocument.body; = `${mailBody.scrollWidth}px`; = `${mailBody.clientHeight}px`;