0

SoloLearn code playground returns console error

I am trying to add a code project to my portfolio. but sololearn compiler says there is a javascript error, it can't find my variables. Can anyone tell me how to add javascript files to code ? The same code is live and working fine at CSSDeck. Here is the project I am trying to add: http://cssdeck.com/labs/puzzle

4th Dec 2016, 6:42 PM
Towkir Ahmed
Towkir Ahmed - avatar
3 Réponses
+ 1
The document (DOM) doesn't appear to be ready when the javascript runs; the length of the box array is 0 if you use SoloLearn's javascript pane. If you place the javascript in the html just before </body> everything's fine: <script type="text/javascript"> .... </script> </body> ... They might be inserting that pane into <head> in which case you'd have to use something like jquery's document.ready() function. https://code.sololearn.com/Wz71RpT00D4B/# Let me know if I should delete that/give credit please.
4th Dec 2016, 8:02 PM
Kirk Schafer
Kirk Schafer - avatar
+ 1
Thanks a lot for your answer Krik Schafer. If you like that, you can use and give credit :) Have a nice day !
5th Dec 2016, 3:55 AM
Towkir Ahmed
Towkir Ahmed - avatar
+ 1
Note, there's also the <body onload="loadfunction()"> ... </body> approach from the course. I didn't think about that and it's potentially cleaner.
5th Dec 2016, 12:46 PM
Kirk Schafer
Kirk Schafer - avatar