2016-11-16 48 views
2

代碼如下:從Chrome中IFRAME打開PDF失敗,默認的PDF查看

<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查看器引起的?如何避免它?

回答

0

事實證明,沙箱使iframe失去了在Chrome上訪問PDF文件的權限,但所有其他Web瀏覽器都沒有這種行爲。

刪除後sandbox="allow-same-origin allow-popups allow-forms allow-scripts",它的工作原理。

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