1
I have a canvas
and I need to put how background
an image that is already on the screen.
Example:
<div id="imagens">
<canvas id="canvas" width="600" height="700" style="border: 1px solid black"></canvas>
</div>
I have this fraction of code that puts an image of the site as backgroud
document.getElementById("canvas").style.backgroundImage = "url('http://www.xxxxxx.yyy.br/1005.jpg')";
But I need to get the picture that’s on id="imgpreview"
and places it as the background of CANVAS.
Thank you lazyFox your first alternative worked correctly.
– Eduardo
And the second no? Consider marking this question as a solution if no more answers emerge.
– lazyFox
For some reason the 2nd didn’t work....
– Eduardo
Maybe your image is not loaded yet when the code is executed, I made a small change in the answer code see if it makes a difference in the final result.
– lazyFox