diff --git a/dev/index.html b/dev/index.html index 0880f68..10bcedd 100644 --- a/dev/index.html +++ b/dev/index.html @@ -121,10 +121,12 @@

Tests

document.getElementById("quicklaunch").addEventListener("click", function(e){ e.preventDefault(); let links = document.querySelectorAll("#examples li a"); - links.forEach(function(link){ - window.open(link.href, "_blank"); - }); + //Can't use forEach because IE11 doesn't support it + for(let i=0; i diff --git a/dev/pdfobject.2.3b.js b/dev/pdfobject.2.3b.js index f3d4bc9..a07e755 100644 --- a/dev/pdfobject.2.3b.js +++ b/dev/pdfobject.2.3b.js @@ -216,15 +216,33 @@ let convertBase64ToDownloadableLink = function (b64, filename, targetNode, fallbackHTML) { - fetch(b64).then(response => response.blob()).then(blob => { - let link = document.createElement('a'); - link.innerText = "Download PDF"; - link.href = URL.createObjectURL(blob); - link.download = filename; - targetNode.innerHTML = fallbackHTML.replace(/\[pdflink\]/g, link.outerHTML); - }); - - } + //IE-11 safe version. More verbose than modern fetch() + if (window.Blob && window.URL && window.URL.createObjectURL) { + + var xhr = new XMLHttpRequest(); + xhr.open('GET', b64, true); + xhr.responseType = 'blob'; + xhr.onload = function() { + + if (xhr.status === 200) { + + var blob = xhr.response; + var link = document.createElement('a'); + link.innerText = "Download PDF"; + link.href = URL.createObjectURL(blob); + link.setAttribute('download', filename); + targetNode.innerHTML = fallbackHTML.replace(/\[pdflink\]/g, link.outerHTML); + + } + + }; + + xhr.send(); + + } + + }; + let generatePDFObjectMarkup = function (embedType, targetNode, url, pdfOpenFragment, width, height, id, title, omitInlineStyles, customAttribute, PDFJS_URL){ diff --git a/dev/tests/pdf-open-params.html b/dev/tests/pdf-open-params.html index 9948064..f3fc48d 100644 --- a/dev/tests/pdf-open-params.html +++ b/dev/tests/pdf-open-params.html @@ -258,9 +258,11 @@

PDFObject Example: PDF Open Parameters

}; -document.querySelectorAll("li a").forEach(function(el){ - el.addEventListener("click", clickHandler); -}) +//Can't use forEach because IE11 doesn't support it +let links = document.querySelectorAll("li a"); +for(let i=0; i diff --git a/dev/tests/pdfjs.html b/dev/tests/pdfjs.html index 74dd631..7746e1b 100644 --- a/dev/tests/pdfjs.html +++ b/dev/tests/pdfjs.html @@ -42,7 +42,7 @@

PDFObject Example: PDF.js fallback