+ 3

What the error with c

I copied this code .. and it works fine on my browser but it give me errors .. and I don't who to fix it . https://code.sololearn.com/WmjlkoiXx1fN/?ref=app

1st Jan 2019, 3:55 AM
2Math
2Math - avatar
5 Respuestas
+ 3
c is canvas. You need to get DOM element. window.onload = function () { var c = document.getElementById("c") ; ... Your other scripts... }
1st Jan 2019, 4:03 AM
Gordon
Gordon - avatar
+ 3
Gordon thx for your care I did as you said but still have an error in line 7 in js code
1st Jan 2019, 4:14 AM
2Math
2Math - avatar
+ 3
No thanks it works now Gordon
1st Jan 2019, 4:16 AM
2Math
2Math - avatar
+ 2
Oh. You already have that part, in HTML body In this case, Put your codes in js tab under line 13 of your html.
1st Jan 2019, 4:04 AM
Gordon
Gordon - avatar
+ 2
Welcome Can you mark [SOLVED] in your question? Also, I should explain a little bit The code playground will put scripts in all three tabs into one html The scripts in js tab will be put in end of head. And the script will run before the DOM exist. So getElement methods will return null. There are two ways to solve it. One way is putting the script at end of body in html tab Another way is to assign the scripts as callback attaching to load listener of window.
1st Jan 2019, 4:22 AM
Gordon
Gordon - avatar