+ 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

10th Oct 2019, 6:43 AM
Razbry
Razbry - avatar
6 Respuestas
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.
11th Oct 2019, 7:05 AM
ODLNT
ODLNT - avatar
+ 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.
10th Oct 2019, 11:52 AM
ODLNT
ODLNT - avatar
+ 1
No because both use the same js engine
10th Oct 2019, 7:29 AM
Nico Ruder
Nico Ruder - avatar
+ 1
Thanks to all of you
11th Oct 2019, 4:34 AM
Razbry
Razbry - avatar
+ 1
I thik i fixed the bug can you please check it again😁😁 And do i need to do this with all my code?
11th Oct 2019, 4:42 AM
Razbry
Razbry - avatar
0
Thank you all of you for your advise Finally I fixed the bug
12th Oct 2019, 4:56 AM
Razbry
Razbry - avatar