使用默认PDF查看器从Chrome IFRAME打开PDF失败 [英] Open PDF from Chrome IFRAME failed with default PDF viewer

查看:742
本文介绍了使用默认PDF查看器从Chrome IFRAME打开PDF失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

代码如下所示:

< iframe pm-attr- iframe class =widget-bodyng-src ={{vm.iframeUrl}}sandbox =allow-same-origin allow-popups allow-forms allow-top-navigation> (不可用)< / iframe>

点击PDF链接在iframe内部,它以白色内容打开。
如果右键单击鼠标并点击保存,它就会起作用。



如果打开任何选项卡或窗口的URL,则使用默认PDF如果我将其他PDF阅读器添加到Chrome扩展程序,它始终有效。



是否是由于Chrome的默认PDF查看器?如何避免它?

解决方案

事实证明,沙盒让iframe失去了在Chrome上访问PDF文件的权限,但所有其他Web浏览器都不有这样的行为。


$ b 删除 sandbox =允许同源允许弹出窗口允许窗体允许脚本
 < iframe pm-attr-iframe class =widget-bodyng-src = {{vm.iframeUrl}}> 
(不可用)
< / iframe>


The code looks like:

    <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>

Click the PDF link inside the iframe, it opens with white content. If right click the mouse and click "Save", it works.

If open the URL to any tab or window, the PDF file rendered with default PDF viewer.

If I add other PDF viewer to Chrome extensions, it always works.

Is it caused by default PDF viewer of Chrome? How to avoid it?

解决方案

It turns out the sandbox make the iframe lost permission to access the PDF file on Chrome, but all other web browsers do not have this behaviour.

After remove sandbox="allow-same-origin allow-popups allow-forms allow-scripts", it works.

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

这篇关于使用默认PDF查看器从Chrome IFRAME打开PDF失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆