我目前正在致力于一个网站,该网站必须通过使用iframe从其他网站下载内容。有什么方法可以裁剪下载的页面的内容,只在我的网站上显示该页面的一部分?如何裁剪Iframe的内容以显示页面的一部分?
10
A
回答
26
有没有什么办法可以裁剪下载页面的内容,只显示我网站上该页面的一部分?
否。同源策略可以防止您以任何方式操纵iframe
,包括滚动位置。
会有一种解决方法通过将iframe
成一个div
容器,其具有限定的高度和宽度,以及overflow: hidden
裁剪的视图端口:
<div style="width: 500px; height: 500px; overflow: hidden">
并给予iframe
的相对位置:
<iframe src="..." style="position: relative; left: -100px; top: -100px">
这样,您可以调整页面上可见的iframe部分。然而,整个页面仍然呈现,并且这种方法不能抵抗诸如在iframe内滚动的影响。
0
在iframe中你不能做到这一点......但如果你使用的HttpWebRequest/WebResponse的那么它很简单......
http://www.codeproject.com/KB/IP/httpwebrequest_response.aspx
http://htmlagilitypack.codeplex.com/
这包是非常重要的......你可以通过ID读取特定的div/span ...
4
<div style="position: absolute; left: 0px; top: 0px; border: solid 2px #555; width:594px; height:332px;">
<div style="overflow: hidden; margin-top: -100px; margin-left: -25px;">
</div>
<iframe src="http://www.centricle.com/tools/html-entities/" scrolling="no" style="height: 490px; border: 0px none; width: 619px; margin-top: -60px; margin-left: -24px; ">
</iframe>
</div>
</div>
此代码适用于我。
来源[http://extechbuzz.blogspot.com/2012/12/iframe-how-to-display-specific-part-of.html]
0
要在嵌入式page底部剪切掉广告,我用下面的:
<div style="width: 1000px; height: 390px; overflow: hidden">
<iframe src="https://openflights.org/user/dankohn1" width="1000"
height="600" style="border:none" scrolling="no">
</iframe></div>
0
此代码为我工作...调整边距并保留任何最适合您的值,并将iframe的高度和宽度调整为您想要的任何值。
<html>
<div style="overflow: hidden; margin-top: -1440px; margin-left:0;">
<iframe src="https://fiitjeelogin.com/StartPage.aspx" scrolling="no" height="1550"width="300" frameBorder="0">
</iframe>
</div>
</html>