簡體   English   中英

彈出以打開pdf在Internet Explorer上不起作用

[英]pop up to open pdf does not work on Internet explorer

我使用一個小的Java腳本在一個較小的選項卡中打開pdf文檔:

 // JavaScript Document function openHeyPopup(objectLink) { window.open(objectLink, "Externer Link", "width=700,height=600,scrollbars=yes"); } function initHeyPopup() { if (!document.getElementsByTagName){ return; } var anchors = document.getElementsByTagName("a"); // loop through all anchor tags for (var i=0; i<anchors.length; i++){ var anchor = anchors[i]; if (anchor.getAttribute("href") && (anchor.getAttribute("rel") == "heypopup")){ anchor.onclick = function () {openHeyPopup(this); return false;} } } } function addLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload != 'function'){ window.onload = func; } else { window.onload = function(){ oldonload(); func(); } } } addLoadEvent(initHeyPopup); // run initLightbox onLoad 

這適用於chrome和Firefox。 但是在Internet Explorer中,我得到了一個空的瀏覽器窗口。

http://www.interieursalon.com/wp/wp-content/uploads/2016/08/web-interieursalon-portfolio.pdf

有人沒有我該如何為IE修復此問題?

最好的祝福

由於安全原因,在IE中,將阻止打開內容不安全的新標簽頁。 我們可以嘗試以下代碼,以幫助我們下載文件。

//window.navigator checks for IE version if yes, it gets executed and in place of  data give your blob.

if (window.navigator && window.navigator.msSaveOrOpenBlob) {
            return window.navigator.msSaveOrOpenBlob(data, "data.pdf");
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM