Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Window is not allowed to navigate Top-frame navigations to data URLs

Earlier following code would open a pdf file in a new window.

var pdfDocument = "data:application/pdf;base64," + data;
window.open(pdfDocument);

After updating chrome, it seems to stop working. Appranely, chrome removed Top-frame navigations to data URLs.

How can I solve my issue now? I need to open this pdf in a new window. Any help will be appreciated.

UPDATE

Solved it using iFrame. Thanks to Pedro for giving me the idea.

<iframe id="ManualFrame"
        frameborder="0"
        style="border:0"
        allowfullscreen>
</iframe>

<script>
    $(function () {
        setManualFrame();
    });

    function setManualFrame() {
        $("#ManualFrame").attr("height", screen.height);
        $("#ManualFrame").attr("width", screen.width);
        $("#ManualFrame").attr("src", "data:application/pdf;base64," + '@ViewBag.pdf_base64_data');
    }
</script>
like image 836
Lonely Planeteer Avatar asked Aug 10 '17 01:08

Lonely Planeteer


1 Answers

Deprecations and Removals in Chrome 60:

Remove content-initiated top frame navigations to data URLs

Because of their unfamiliarity to non-technical browser users, we're increasingly seeing the data: scheme being used in spoofing and phishing attacks. To prevent this, we're blocking web pages from loading data: URLs in the top frame. This applies to tags, window.open, window.location and similar mechanisms. The data: scheme will still work for resources loaded by a page.

This feature was deprecated in Chrome 58 and is now removed.

Source: https://developers.google.com/web/updates/2017/06/chrome-60-deprecations

like image 110
Cafer Can Arslan Avatar answered Nov 11 '22 23:11

Cafer Can Arslan