[筆記]Different ways to embed pdf viewer

Q: 有甚麼方式在網頁中檢視PDF,且不需 JavaScript?

A: 可以使用 HTML <object><embed><iframe>

不過,瀏覽器的支援度,IE 需要安裝如 Adobe PDF,使用其提供的瀏覽器套件,才能在網頁中檢視。

object

1
2
3
4
5
<object id='viewer_1'
data='/assets/pdf/lorem-doc.pdf'
type='application/pdf'>
Your brower does not support PDF. Please download <a href='/assets/pdf/compressed.tracemonkey-pldi-09.pdf'>it</a>
</object>

Your brower does not support PDF. Please download it

embed

1
2
3
<embed id='viewer_2'
src='/assets/pdf/lorem-doc.pdf'
type='application/pdf'/>

iframe

1
2
3
4
<iframe id='viewer_3'
src='/assets/pdf/lorem-doc.pdf'>
Your brower does not support PDF. Please download <a href='/assets/pdf/lorem-doc.pdf'>it</a>
</iframe>