0
Why I can't use getContext in soloLearn app while it work good in other software
Error occurs when I try to getContext https://code.sololearn.com/WjQ53ZnW68oc/?ref=app
2 Respostas
+ 4
Wrap your js code inside the following function
window.onload=function(){
}
On sololearn for some reason js gets executed before Dom is loaded so therefore trying to get element that doesn't exist returns that error ,the above function stops js from getting excuted until HTML Dom is loaded
+ 3
In SL the JavaScript code is executed before the page is loaded so the canvas element was not created yet. Either wrap your code in window.onload() or write your script in HTML section after the canvas.