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