+ 1
Code malfunctioning
Can it happen that the code that I wrote(in JavaScript) on my ios device may not work on an Android devices? Please tell me wether this code is working for everyone. https://code.sololearn.com/WV9xGAw5500h/?ref=app
6 ответов
0
Razbry
I ran your code again and got the same error message. The simple fix is to wrap your code in a function then evoke that function when the document is loaded.
https://code.sololearn.com/We7ysgOfHRFb/#js
Unfortunately, yes you will have to do this with any code that accesses the DOM. Keep in that this is Sololearn Playground specific.
+ 2
Razbry
I got an error message "Uncaught TypeError: Cannot read property 'getContext' of null
Line: 2", when I ran your code on my pc and android phone.
This error is normally due to the script being ran before the document is loaded. You will most likely need to add an onload event to run the script after the document is loaded.
+ 1
No because both use the same js engine
+ 1
Thanks to all of you
+ 1
I thik i fixed the bug can you please check it again😁😁
And do i need to do this with all my code?
0
Thank you all of you for your advise
Finally I fixed the bug