1

Lets say that I have an iframe that renders some html that I provide. The iframe has a fixed height. It renders what it can inside it's height and shows scrollbar for the rest.

My question is, how can I fetch the html contents of the iframe that are visible in the viewport using javascript.

I only want to get the contents that are visible, not the ones that are hidden under the scroll.

enter image description here

i.e. I only want to fetch the marked contents as a javascript document enter image description here

Muhammadpen
  • 55
  • 2
  • 10
  • Do you want to change the height of the iframe to match the contents of what it is displaying, and as a result removing the scroll bar? Or do you just want to remove the scroll bar, and as a result have content that doesn't fit? – 3limin4t0r Nov 25 '22 at 14:57
  • @3limin4t0r I've updated my question to be more clear. I actually want to get the text contents inside the iframe. but I only want to get the contents that are currently visible on screen. – Muhammadpen Nov 26 '22 at 06:16

1 Answers1

0

Have you tried the scrolling="no"?

<iframe scrolling="no" src="http://www.google.com" width="400px" height="300"></iframe>
Alex
  • 208
  • 1
  • 6
  • I've updated my question to be more clear. I actually want to get the text contents inside the iframe. but I only want to get the contents that are currently visible on screen. – Muhammadpen Nov 26 '22 at 06:16