I have a script which converts a canvas element to an <img>
tag and then reloads it in a new window (about:blank page). If I then right-click the image and select 'Open Image In New Tab' it opens the Base64 DataURL (i.e. Just the image).
Is there any way to open the Base64 DataURL without the user having to right-click the image?
Ideally, the user would never even see the about:blank page and would simply be redirected to the DataURL.
Here is the current code that generates the image and opens it in a new window:
<script>
function print_card(){
var canvas=document.getElementById("canvas");
var win=window.open();
win.document.write("<img id='compiledImg' src='"+canvas.toDataURL('image/png')+"' width='324' height='204' style='margin: 0; padding: 0; background: #e6e6e6;'/>");
win.location.assign(reload);
}
$("#printCard").click(function(){ print_card(); });
</script>
It seems like I should be able to get the dataURL from the image id and redirect to it as opposed to a new window, but I have no idea how to accomplish it.
I tried assigning canvas.toDataURL('image/png)
to win.location
but that did not help.
Any guidance would be much appreciated.