JavaScript, open pdf encoded to Base64 in a new tab without downloading it in Google-Chrome












0















After reading this I understand that the desirable



window.open('data:application/pdf;base64,' + pdfDataBase64);


is not working because Google removed top-frame navigations to data URLs.



I found a nice workaround here so I replaced my code with



var win = window.open();
win.document.write('<iframe src="data:application/pdf;base64,' + pdfDataBase64 + '" frameborder="0" style="border:0; top:0px; left:0px; bottom:0px; right:0px; width:100%; height:100%;" allowfullscreen></iframe>');


which works but gives me this in the console:




[Deprecation] HTML Imports is deprecated and will be removed in M73,
around March 2019. Please use ES modules instead. See
https://www.chromestatus.com/features/5144752345317376 for more
details.



[Deprecation]
document.registerElement is deprecated and will be removed in M73,
around March 2019. Please use window.customElements.define instead.
See https://www.chromestatus.com/features/4642138092470272 for more
details.
(anonymous) @ polymer-micro-extracted.js:442



[Deprecation] Element.createShadowRoot
is deprecated and will be removed in M73, around March 2019. Please
use Element.attachShadow instead. See
https://www.chromestatus.com/features/4507242028072960 for more
details.
_createLocalRoot @ polymer-mini-extracted.js:2083




I am not so familiar with javascript and I'm afraid that the code I'm using now won't work as of March 2019.



Is there any reason for concern or should I ignore this messages?



Is there any other way I can open the Base64 pdf in a new tab, without downloading it?










share|improve this question























  • It's coming from polymer-micro-extracted.js, do you have some chrome extension plugin,.. Your code shouldn't be the cause here.

    – Keith
    Nov 28 '18 at 12:32











  • @Keith, I saw that but I didn't know how to interpret it, I don't have any chrome extensions other than Google Docs. I am not sure when or why polymer-mini-extracted.js is running

    – ioansen
    Nov 28 '18 at 12:42











  • It's maybe what your using to view pdf's,. But opening a pdf inside an iframe shouldn't be giving you any errors, if it does, it's the pdf viewer that's doing it. Normally in chrome if you click on the Javascript file, it will open & it might then give some hints were it's coming from.

    – Keith
    Nov 28 '18 at 12:48











  • Also, to have full control of viewing PDF's, instead of relying on whatever PDF viewer the user has registered, you could have a look at mozilla.github.io/pdf.js You then wouldn't even need an iFrame.

    – Keith
    Nov 28 '18 at 12:50











  • @Keith so the warnings are coming from the chrome's pdf viewer, I see now. I should't worry about them then, thank you

    – ioansen
    Nov 28 '18 at 12:59
















0















After reading this I understand that the desirable



window.open('data:application/pdf;base64,' + pdfDataBase64);


is not working because Google removed top-frame navigations to data URLs.



I found a nice workaround here so I replaced my code with



var win = window.open();
win.document.write('<iframe src="data:application/pdf;base64,' + pdfDataBase64 + '" frameborder="0" style="border:0; top:0px; left:0px; bottom:0px; right:0px; width:100%; height:100%;" allowfullscreen></iframe>');


which works but gives me this in the console:




[Deprecation] HTML Imports is deprecated and will be removed in M73,
around March 2019. Please use ES modules instead. See
https://www.chromestatus.com/features/5144752345317376 for more
details.



[Deprecation]
document.registerElement is deprecated and will be removed in M73,
around March 2019. Please use window.customElements.define instead.
See https://www.chromestatus.com/features/4642138092470272 for more
details.
(anonymous) @ polymer-micro-extracted.js:442



[Deprecation] Element.createShadowRoot
is deprecated and will be removed in M73, around March 2019. Please
use Element.attachShadow instead. See
https://www.chromestatus.com/features/4507242028072960 for more
details.
_createLocalRoot @ polymer-mini-extracted.js:2083




I am not so familiar with javascript and I'm afraid that the code I'm using now won't work as of March 2019.



Is there any reason for concern or should I ignore this messages?



Is there any other way I can open the Base64 pdf in a new tab, without downloading it?










share|improve this question























  • It's coming from polymer-micro-extracted.js, do you have some chrome extension plugin,.. Your code shouldn't be the cause here.

    – Keith
    Nov 28 '18 at 12:32











  • @Keith, I saw that but I didn't know how to interpret it, I don't have any chrome extensions other than Google Docs. I am not sure when or why polymer-mini-extracted.js is running

    – ioansen
    Nov 28 '18 at 12:42











  • It's maybe what your using to view pdf's,. But opening a pdf inside an iframe shouldn't be giving you any errors, if it does, it's the pdf viewer that's doing it. Normally in chrome if you click on the Javascript file, it will open & it might then give some hints were it's coming from.

    – Keith
    Nov 28 '18 at 12:48











  • Also, to have full control of viewing PDF's, instead of relying on whatever PDF viewer the user has registered, you could have a look at mozilla.github.io/pdf.js You then wouldn't even need an iFrame.

    – Keith
    Nov 28 '18 at 12:50











  • @Keith so the warnings are coming from the chrome's pdf viewer, I see now. I should't worry about them then, thank you

    – ioansen
    Nov 28 '18 at 12:59














0












0








0








After reading this I understand that the desirable



window.open('data:application/pdf;base64,' + pdfDataBase64);


is not working because Google removed top-frame navigations to data URLs.



I found a nice workaround here so I replaced my code with



var win = window.open();
win.document.write('<iframe src="data:application/pdf;base64,' + pdfDataBase64 + '" frameborder="0" style="border:0; top:0px; left:0px; bottom:0px; right:0px; width:100%; height:100%;" allowfullscreen></iframe>');


which works but gives me this in the console:




[Deprecation] HTML Imports is deprecated and will be removed in M73,
around March 2019. Please use ES modules instead. See
https://www.chromestatus.com/features/5144752345317376 for more
details.



[Deprecation]
document.registerElement is deprecated and will be removed in M73,
around March 2019. Please use window.customElements.define instead.
See https://www.chromestatus.com/features/4642138092470272 for more
details.
(anonymous) @ polymer-micro-extracted.js:442



[Deprecation] Element.createShadowRoot
is deprecated and will be removed in M73, around March 2019. Please
use Element.attachShadow instead. See
https://www.chromestatus.com/features/4507242028072960 for more
details.
_createLocalRoot @ polymer-mini-extracted.js:2083




I am not so familiar with javascript and I'm afraid that the code I'm using now won't work as of March 2019.



Is there any reason for concern or should I ignore this messages?



Is there any other way I can open the Base64 pdf in a new tab, without downloading it?










share|improve this question














After reading this I understand that the desirable



window.open('data:application/pdf;base64,' + pdfDataBase64);


is not working because Google removed top-frame navigations to data URLs.



I found a nice workaround here so I replaced my code with



var win = window.open();
win.document.write('<iframe src="data:application/pdf;base64,' + pdfDataBase64 + '" frameborder="0" style="border:0; top:0px; left:0px; bottom:0px; right:0px; width:100%; height:100%;" allowfullscreen></iframe>');


which works but gives me this in the console:




[Deprecation] HTML Imports is deprecated and will be removed in M73,
around March 2019. Please use ES modules instead. See
https://www.chromestatus.com/features/5144752345317376 for more
details.



[Deprecation]
document.registerElement is deprecated and will be removed in M73,
around March 2019. Please use window.customElements.define instead.
See https://www.chromestatus.com/features/4642138092470272 for more
details.
(anonymous) @ polymer-micro-extracted.js:442



[Deprecation] Element.createShadowRoot
is deprecated and will be removed in M73, around March 2019. Please
use Element.attachShadow instead. See
https://www.chromestatus.com/features/4507242028072960 for more
details.
_createLocalRoot @ polymer-mini-extracted.js:2083




I am not so familiar with javascript and I'm afraid that the code I'm using now won't work as of March 2019.



Is there any reason for concern or should I ignore this messages?



Is there any other way I can open the Base64 pdf in a new tab, without downloading it?







javascript google-chrome pdf base64






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 28 '18 at 12:22









ioansenioansen

11




11













  • It's coming from polymer-micro-extracted.js, do you have some chrome extension plugin,.. Your code shouldn't be the cause here.

    – Keith
    Nov 28 '18 at 12:32











  • @Keith, I saw that but I didn't know how to interpret it, I don't have any chrome extensions other than Google Docs. I am not sure when or why polymer-mini-extracted.js is running

    – ioansen
    Nov 28 '18 at 12:42











  • It's maybe what your using to view pdf's,. But opening a pdf inside an iframe shouldn't be giving you any errors, if it does, it's the pdf viewer that's doing it. Normally in chrome if you click on the Javascript file, it will open & it might then give some hints were it's coming from.

    – Keith
    Nov 28 '18 at 12:48











  • Also, to have full control of viewing PDF's, instead of relying on whatever PDF viewer the user has registered, you could have a look at mozilla.github.io/pdf.js You then wouldn't even need an iFrame.

    – Keith
    Nov 28 '18 at 12:50











  • @Keith so the warnings are coming from the chrome's pdf viewer, I see now. I should't worry about them then, thank you

    – ioansen
    Nov 28 '18 at 12:59



















  • It's coming from polymer-micro-extracted.js, do you have some chrome extension plugin,.. Your code shouldn't be the cause here.

    – Keith
    Nov 28 '18 at 12:32











  • @Keith, I saw that but I didn't know how to interpret it, I don't have any chrome extensions other than Google Docs. I am not sure when or why polymer-mini-extracted.js is running

    – ioansen
    Nov 28 '18 at 12:42











  • It's maybe what your using to view pdf's,. But opening a pdf inside an iframe shouldn't be giving you any errors, if it does, it's the pdf viewer that's doing it. Normally in chrome if you click on the Javascript file, it will open & it might then give some hints were it's coming from.

    – Keith
    Nov 28 '18 at 12:48











  • Also, to have full control of viewing PDF's, instead of relying on whatever PDF viewer the user has registered, you could have a look at mozilla.github.io/pdf.js You then wouldn't even need an iFrame.

    – Keith
    Nov 28 '18 at 12:50











  • @Keith so the warnings are coming from the chrome's pdf viewer, I see now. I should't worry about them then, thank you

    – ioansen
    Nov 28 '18 at 12:59

















It's coming from polymer-micro-extracted.js, do you have some chrome extension plugin,.. Your code shouldn't be the cause here.

– Keith
Nov 28 '18 at 12:32





It's coming from polymer-micro-extracted.js, do you have some chrome extension plugin,.. Your code shouldn't be the cause here.

– Keith
Nov 28 '18 at 12:32













@Keith, I saw that but I didn't know how to interpret it, I don't have any chrome extensions other than Google Docs. I am not sure when or why polymer-mini-extracted.js is running

– ioansen
Nov 28 '18 at 12:42





@Keith, I saw that but I didn't know how to interpret it, I don't have any chrome extensions other than Google Docs. I am not sure when or why polymer-mini-extracted.js is running

– ioansen
Nov 28 '18 at 12:42













It's maybe what your using to view pdf's,. But opening a pdf inside an iframe shouldn't be giving you any errors, if it does, it's the pdf viewer that's doing it. Normally in chrome if you click on the Javascript file, it will open & it might then give some hints were it's coming from.

– Keith
Nov 28 '18 at 12:48





It's maybe what your using to view pdf's,. But opening a pdf inside an iframe shouldn't be giving you any errors, if it does, it's the pdf viewer that's doing it. Normally in chrome if you click on the Javascript file, it will open & it might then give some hints were it's coming from.

– Keith
Nov 28 '18 at 12:48













Also, to have full control of viewing PDF's, instead of relying on whatever PDF viewer the user has registered, you could have a look at mozilla.github.io/pdf.js You then wouldn't even need an iFrame.

– Keith
Nov 28 '18 at 12:50





Also, to have full control of viewing PDF's, instead of relying on whatever PDF viewer the user has registered, you could have a look at mozilla.github.io/pdf.js You then wouldn't even need an iFrame.

– Keith
Nov 28 '18 at 12:50













@Keith so the warnings are coming from the chrome's pdf viewer, I see now. I should't worry about them then, thank you

– ioansen
Nov 28 '18 at 12:59





@Keith so the warnings are coming from the chrome's pdf viewer, I see now. I should't worry about them then, thank you

– ioansen
Nov 28 '18 at 12:59












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53519402%2fjavascript-open-pdf-encoded-to-base64-in-a-new-tab-without-downloading-it-in-go%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53519402%2fjavascript-open-pdf-encoded-to-base64-in-a-new-tab-without-downloading-it-in-go%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Contact image not getting when fetch all contact list from iPhone by CNContact

count number of partitions of a set with n elements into k subsets

A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks