2012-11-22 78 views
0

我在我的iframe中有一個有邊框的區域。代碼是這樣的:如何在邊界區域顯示pdf?

<div> 
<center> 
<div style="width:600px;height:245px;border:3px solid grey;"> 
</div> 
</center> 
</div> 

這會在我的iframe中創建一個有邊框的灰色區域。現在,我希望用戶查看PDF時,他只需在具有垂直和水平滾動條的邊界區域內打開iframe。 PDF格式坐落在這個網址:

http://www.irs.gov/pub/irs-pdf/fw4.pdf

我怎樣才能做到這一點?請幫助。

回答

1

另外,如果你不想使用框架,你可以inlude PDF作爲對象。現在您可能會想到一個問題(使用哪種方法?)Why people use <object classid=""> to show PDF instead of src="1.pdf"

典型用法如下;

<!--[if IE]> 
<object classid="clsid:CA8A9780-280D-11CF-A24D-444553540000" data="http://www.irs.gov/pub/irs-pdf/fw4.pdf"> 
<p>backup content</p> 
</object> 
<![endif]--> 

<!--[if !IE]> <--> 
<object type="application/pdf" data="http://www.irs.gov/pub/irs-pdf/fw4.pdf" style="width:100%; height:100%"> 
<p>backup content</p> 
</object> 
<!--> 
<![endif]--> 

你可以看看這裏的慣例和CSS問題對於其他類型的對象元素。 http://joliclic.free.fr/html/object-tag/en/index.php

+0

這真的很好,upvoted和接受。謝謝。我從src開始,現在根據你的建議,我已經轉向了對象類型。再次感謝 。 –

0

只需通過PDF鏈接在IFRAME SRC值:

... 
<center> 

    <iframe runat="server" src="http://www.irs.gov/pub/irs-pdf/fw4.pdf " 
    width="600px" height="245px" id="iframeDash" frameborder="1" > 

</center> 
...