2011-04-15 82 views

回答

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內滾動的影響。

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>