Canvas javascript error | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Canvas javascript error

Ok guys Hey, i don't undestand what is wrong here they say it's an error at line 2 In javascript canvas.getContext https://code.sololearn.com/WZ89E8a70Q87/?ref=app

31st Dec 2018, 1:36 AM
Brandy
Brandy - avatar
7 Answers
+ 1
Add all JS into onload callback function. https://code.sololearn.com/W1JT9X3yNqox/?ref=app
31st Dec 2018, 1:55 AM
Calviղ
Calviղ - avatar
+ 1
onload = function () { // add your javascript codes here }
31st Dec 2018, 2:01 AM
Calviղ
Calviղ - avatar
+ 1
ctx=canvas.getContext("2d")
31st Dec 2018, 2:23 AM
Calviղ
Calviղ - avatar
+ 1
Ok thanks u a lot !
31st Dec 2018, 2:24 AM
Brandy
Brandy - avatar
0
When I wrote this in my computer that's work well but here no.. :(
31st Dec 2018, 1:37 AM
Brandy
Brandy - avatar
0
Can you show me an example please ?
31st Dec 2018, 2:00 AM
Brandy
Brandy - avatar
0
Nan bro :/
31st Dec 2018, 2:03 AM
Brandy
Brandy - avatar