0

I want to ask you what's wrong with my code below :

var myCanvas = document.getElementById('myCanvas');
var ctx = myCanvas.getContext('2d');

var image = new Image();
image.onload = onLoad;
image.src = './PS_Countdown.jpeg';
ctx.drawImage(image, 25, 25);

function onLoad() {
    console.log('Image loaded');
}
nanobash
  • 5,419
  • 7
  • 38
  • 56
Francesco
  • 349
  • 5
  • 10
  • 1
    Is the image located in that folder? – gen_Eric Feb 22 '13 at 16:39
  • 2
    according to your error, it can't find that file. Is the location correct? it's `.jpeg`? and the `./` is correct? Also, you may want to move the `drawImage` line into the `onLoad` function so that you HAVE the image before you try to use it – Robot Woods Feb 22 '13 at 16:40
  • I changed the extension from .jpeg to .jpg, but id doesn't work anyway. The location is correct because the image is in the same folder of the script. – Francesco Feb 22 '13 at 17:20

0 Answers0