I want to change background dynamically in JS and my set of images is in base64 encoded. I try:
document.getElementById(\"bg_image\").style.backgroundImage =
Adding this trick to gabriel garcia's following solution -
var img = 'data:image/png;base64, ...'; //place ur base64 encoded img here
document.body.style.backgroundImage = 'url(' + img + ')';
However, in my case this wasn't working. Moving url into the img variable did the trick. SO the final code looked like this
var img = "url('data:image/png;base64, "+base64Data + "')";
document.body.style.backgroundImage = img;