Open PDF from Chrome IFRAME failed with default PDF viewer

家住魔仙堡 提交于 2019-12-12 18:48:24

问题


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?


回答1:


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>


来源:https://stackoverflow.com/questions/40624211/open-pdf-from-chrome-iframe-failed-with-default-pdf-viewer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!