使用默认PDF查看器

时间:2016-11-16 04:42:59

标签: html google-chrome iframe pdf-viewer

代码如下:

    <iframe pm-attr-iframe class="widget-body" ng-src="{{vm.iframeUrl}}"  sandbox="allow-same-origin allow-popups allow-forms allow-top-navigation">
    (not available)
</iframe>

点击iframe中的PDF链接,它会以白色内容打开。 如果右键单击鼠标并单击“保存”,则可以正常工作。

如果打开任何标签或窗口的URL,则使用默认的PDF查看器呈现PDF文件。

如果我将其他PDF查看器添加到Chrome扩展程序,它始终有效。

是否由Chrome的默认PDF查看器引起?怎么避免呢?

2 个答案:

答案 0 :(得分:1)

我刚刚找到另一种解决此问题的方法。 如果您的网站出于某种原因需要坚持使用Hi there, everyone!,则可以添加值sandbox来解决此问题。

答案 1 :(得分:0)

事实证明,沙箱使得iframe失去了访问Chrome上PDF文件的权限,但所有其他网络浏览器都没有此行为。

删除sandbox="allow-same-origin allow-popups allow-forms allow-scripts"后,它可以正常工作。

<iframe pm-attr-iframe class="widget-body" ng-src="{{vm.iframeUrl}}">
    (not available)
</iframe>
相关问题