In Chrome and Chromium, upon calling
html2canvas(document.getElementsByClassName('console'), {
onrendered: function(canvas) {
var img = canvas.toDataURL()
window.open(img);
}
});
html2canvas
opens the window that should contain my console
element only to display this error:
Not allowed to navigate top frame to data URL:
Followed by the URL that should display the image.
I was able to find a work around by using an iframe
like such:
html2canvas(document.getElementsByClassName('console'), {
onrendered: function(canvas) {
var img = canvas.toDataURL()
var iframe = '<iframe src="' + img + '" frameborder="0" style="border:0; top:0px; left:0px; bottom:0px; right:0px; width:100%; height:100%;" allowfullscreen></iframe>'
var x = window.open();
x.document.open();
x.document.write(iframe);
x.document.close();
}
});
But note that the display in Chrome still has issues as mentioned here: #1272
Most helpful comment
I was able to find a work around by using an
iframe
like such:But note that the display in Chrome still has issues as mentioned here: #1272