I'm looking into being able to change the background of a webpage to a dynamically generated image at runtime. I'm using javascript and the canvas element to create the backgrounds, which I'm storing in an array so that the user can toggle between them; the images are jpegs
// canvas computations snipped
var img = c.toDataURL("image/jpeg");
this.modifiedanimationarray[0] = new Image();
this.modifiedanimationarray[0].src = img;
However, I have noticed that the javascript to manipulate the background is as follows:
document.body.style.backgroundImage = "url('whatever.jpg')";
it wants an image from a url, that is created non-dynamically. Is there any way to force the document.body.style.backgroundImage to accept an image created on-the-fly rather than just loading one off a domain?