How do I crop the contents of an Iframe to show a part of a page?

前端 未结 5 2050
没有蜡笔的小新
没有蜡笔的小新 2020-12-13 20:37

I am currently working on a website which must download content from another website through the use of an iframe. Is there any way that I can crop the contents of the downl

5条回答
  •  一向
    一向 (楼主)
    2020-12-13 21:20

    Is there any way that I can crop the contents of the downloaded page to only show a section of that page on my website?

    No. The Same Origin Policy prevents you from manipulating the iframe in any way, including the scroll position.

    There would be a workaround by putting the iframe into an a div container that has a defined height and width, and overflow: hidden to clip the view port:

    and giving the iframe a relative position: