0
Why did some javascript code didnt work in sololearn text editor?
hi all, i re-write some code in html, css and js. but if i write the js in js column editor (sololearn text editor), it didnt works. so i changed another method. i write it in html editor in between <script>'yourjsscript'</script> and it works. can you trace the problem regarding this issue? feel free to copy the code and try to find the answer. many thx n regards.
2 Antworten
+ 2
When you put JS code in the JS tab of code playground, it is virtually linking as an external file in the <head> of your html tab...
Probably you put your '<script>/* your code */</script>' in the <body>, after the elements your code need to access: when putting it before ( as is when putting JS in <head> ), you need to wait for html document was loading before attempting to access it with JS.
The simpliest way to fix this js tab 'problem', is to embed all your JS code which are in the JS tab, inside a generic anonym function assigned to the 'onload' event of the window object:
window.onload = function() {
/* all your JS tab code here */
};
( the last semi-colon is required in absolute, even if code playground is very permissive -- more than almost browsers / js interpreters -- with the lack of them )
0
oh i see.. many thx n regards bro..