2

Im editing a HTML book not coded by me from the start. Images are set as div backgrounds with base64 format like this one

<div class="cntnt" style="background-image: url(data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD...... 

the question is : how can I (with javascript) make downloading that image possible by clicking that div or any other button?

Bialy
  • 905
  • 2
  • 12
  • 22

1 Answers1

0

You could use the atob() function which will decode Base64 encoded strings... You would have to split the img url tho.

Example:

var encodedData = window.btoa("Hello, world"); // encode a string
var decodedData = window.atob(encodedData); // decode the string