Hey i need your help and would like to know why this code wont run..There is an current error in line 13/14.. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

Hey i need your help and would like to know why this code wont run..There is an current error in line 13/14..

<!DOCTYPE html> <html> <head> <title> Canvas </title> <script> var img = new Image(); img.src = "Marcjd.jpg"; function draw(){ var ctx = document.getElementById('myCanvas') .getContext('2d'); ctx.drawImage(img, 20, 20); } window.onload=draw; </script> </head> <body> <script> <canvas id="myCanvas" width="300" height="500"> </canvas> </script> </body> </html>

1st Feb 2017, 11:09 PM
Marc
Marc - avatar
2 Answers
+ 1
does "document.getElementById('myCanvas') .getContext('2d');" need to be writren in the same line maybe?
1st Feb 2017, 11:13 PM
Marc
Marc - avatar
0
#body{ background-color: #666; margin:10px; } #myCanvas{ background-color:#FFF; border: 1px solid black; } Thats the css code i use but i dont think its importan for this question
1st Feb 2017, 11:11 PM
Marc
Marc - avatar