UPDATE:
Creating a Blob from a base64 string in JavaScript
I'm currently working on a feature where a user can click a button to download a file from its DataURL.
However, due to Chrome restrictions on building <a>
links, I encountered an error message:
Not allowed to navigate top frame to data URL: ....
To workaround this issue, I discovered that opening a new window with an iframe and setting the DataURL as its src
works:
let jpgWindow = window.open("", "_blank")
var html = "<html><body><iframe width='100%' height='100%' src='data:application/jpeg;base64, "+ theDataURL+"'></iframe></body></html>";
jpgWindow.document.write(html)
Although the download functionality works as intended when the button is clicked, the downloaded picture is saved with the filename "download" by default, without the option to specify a custom file name.
Any suggestions or ideas on how to overcome this issue?