2016-10-04 91 views
0

不工作我用一個小的Java腳本在一個較小的選項卡中打開PDF文檔:彈出來打開PDF在Internet Explorer

// JavaScript Document 
 
function openHeyPopup(objectLink) { 
 

 
\t window.open(objectLink, "Externer Link", "width=700,height=600,scrollbars=yes"); 
 

 
} 
 

 
function initHeyPopup() 
 
{ 
 
\t 
 
\t if (!document.getElementsByTagName){ return; } 
 
\t var anchors = document.getElementsByTagName("a"); 
 

 
\t // loop through all anchor tags 
 
\t for (var i=0; i<anchors.length; i++){ 
 
\t \t var anchor = anchors[i]; 
 

 
\t \t if (anchor.getAttribute("href") && (anchor.getAttribute("rel") == "heypopup")){ 
 
\t \t \t anchor.onclick = function() {openHeyPopup(this); return false;} 
 
\t \t } 
 
\t } 
 

 
} 
 

 
function addLoadEvent(func) 
 
{ \t 
 
\t var oldonload = window.onload; 
 
\t if (typeof window.onload != 'function'){ 
 
    \t window.onload = func; 
 
\t } else { 
 
\t \t window.onload = function(){ 
 
\t \t oldonload(); 
 
\t \t func(); 
 
\t \t } 
 
\t } 
 

 
} 
 

 
addLoadEvent(initHeyPopup); \t // run initLightbox onLoad

這工作正常Chrome和Firefox。但在Internet Explorer中,我得到一個空的瀏覽器窗口。

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

任何人都沒有,我怎麼能解決這個問題的IE?

問候

+0

您是否嘗試過任何調試?它在哪裏失敗?如果您發佈了大量代碼並詢問「爲什麼它不起作用?」,您不太可能得到有用的答案。 – NicolasMoise

+0

另外,你使用的是什麼版本的IE? – NicolasMoise

+0

如果彈出窗口打開,發佈的代碼就起作用了,這很可能與瀏覽器設置,服務器上的服務器設置,或者瀏覽器中使用的Adobe插件有關。 – adeneo

回答

0

在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"); 
}