我们有一个内部网站,其中有一些指向网络服务器上托管的 pdf 文档的链接。如果我打开 Chrome 开发工具(F12),检查链接并添加具有相同 pdf 文档的嵌入,它会下载该文件而不是显示它。我尝试过使用 embed 和 iframe,但仍然遇到同样的问题。
原始代码:
<a id="id2239" href="http://example.com:8080/client/attachment/filename.pdf" class="act01">filename.pdf</a>
Screenshot:
我们想要工作的代码:
<a id="id2239" href="http://example.com:8080/client/attachment/filename.pdf" class="act01">filename.pdf</a>
<div class="fgh"><embed id="fgh" src="http://example.com:8080/client/attachment/filename.pdf" type="application/pdf" width="400" height="400"></div>
截屏:
As you can see, it actually downloads the document instead of showing it in the screenshot above. Just shows a white space.
与另一个文档一起使用的代码:我刚刚在google上找到了一个pdf文档,并将其放入标签中,就可以了。它显示嵌入中的文档,而不下载该文档。
<a id="id2239" href="http://example.com:8080/client/attachment/filename.pdf" class="act01">filename.pdf</a>
<div class="fgh"><embed id="fgh" src="http://infolab.stanford.edu/pub/papers/google.pdf" type="application/pdf" width="400" height="400"></div>
截屏:
问题:
- 为什么这两个例子不同?为什么内部文档可以下载,但外部文档却显示嵌入到页面中?
- 我如何让它也能与您的网络服务器上的文件一起使用?
Edit:
Screenshot of the pdf documents headings.
这取决于响应标头中的内容类型。您可以检查您的网络服务器是否设置了正确的标头信息,例如内容类型:应用程序/pdf。
“Chrome Dev-Tools(F12)”-> Network 选项卡,检查响应标头。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)