如何裁剪 Iframe 的内容以显示页面的一部分? [英] How do I crop the contents of an Iframe to show a part of a page?
问题描述
我目前正在开发一个网站,该网站必须通过使用 iframe 从另一个网站下载内容.有什么方法可以裁剪下载页面的内容以仅在我的网站上显示该页面的一部分?
有什么办法可以裁剪下载页面的内容以仅在我的网站上显示该页面的一部分?
没有.同源策略可防止您以任何方式操纵 iframe
,包括滚动位置.
将 iframe
放入具有定义高度和宽度的 div
容器和 overflow: hidden
剪辑视口:
并给 iframe
一个相对位置:
<iframe src="..." style="position: relative; left: -100px; top: -100px">
通过这种方式,您可以调整页面上可见的 iframe 部分.但是,整个页面仍然会被渲染,并且这种方法无法避免在 iframe 内滚动等影响.
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 downloaded page to only show a section of that page on my website?
解决方案
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:
<div style="width: 500px; height: 500px; overflow: hidden">
and giving the iframe
a relative position:
<iframe src="..." style="position: relative; left: -100px; top: -100px">
this way, you can adjust the portion of the iframe that is visible on the page. However, the whole page still gets rendered, and this approach is not immune to influences like scrolling inside the iframe.
这篇关于如何裁剪 Iframe 的内容以显示页面的一部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文
相关文章
- 如何剪裁的iframe的内容显示页面的一部分?;
- iframe仅显示页面的某一部分;
- 隐藏/显示页面的一部分;
- 隐藏html页面的一部分;
- 仅渲染页面的一部分;
- 如何只打印页面的一部分?;
- 如何只更改页面的一部分;
- 如何打印HTML页面的一部分?;
- 如何导航到页面的一部分;
- jQuery的禁用页面的一部分;
- 刷新页面的一部分;
- 刷新页面的一部分;
- PHP刷新只是页面的一部分;
- 查看 PDF 作为页面的一部分;
- 查看PDF作为页面的一部分;
- jQuery滚动到页面的一部分;
- 仅缓存PHP页面的一部分;
- 如何使用jQuery打印页面的一部分?;
- 如何使用PhantomJS渲染页面的一部分?;
- 如何链接到页面的一部分?(哈希?);
- 如何裁剪位图的一部分并保存裁剪的部分;
- 如何在webbrowser C#中显示页面的一部分;
- 限制tabindex聚焦到页面的一部分;
- Django,更新页面的一部分;
- Python阅读了pdf页面的一部分;
C#/.NET最新文章
- smtp.live.com - 邮箱不可用。服务器响应为:5.7.3请求的操作中止;用户未通过身份验证;
- C#WinForms应用程序失败在发送电子邮件:远程名称无法解析:'smtp.gmail.com;操作超时;
- Windows应用程序已停止工作::事件名称CLR20r3;
- 如何设置的WebAPI控制器的multipart / form-data的;
- 无法反序列化当前的JSON数组(例如[1,2,3]);
- 如何设置一个HttpClient的请求Content-Type头?;
- 为什么发现“没有匹配请求URI的HTTP资源”这里?;
- 如何设置一个重试次数在RabbitMQ的呢?;
- 任务&LT;&GT;不包含'GetAwaiter“的定义;
- 这是不可能连接到redis的服务器(S);以创建断开连接多路复用器;