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>
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With