Script error | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 1

Script error

I dont know why this code works on a laptop, but it fails here for the script https://code.sololearn.com/WIezmSpLcCr9/?ref=app

18th Aug 2018, 4:53 AM
M.akbari
M.akbari - avatar
4 Respostas
+ 4
onload = function() { document.getElementById('aparatCarts').innerHTML=html; }
18th Aug 2018, 5:19 AM
CalviÕ²
CalviÕ² - avatar
+ 4
Because the JavaScript codes on JS pane is injected into head tag node. It run the JavaScript codes before DOM is successsfully loaded. Thus allow it to be called back by onload function would make sure the DOM is loaded before executing the codes.
18th Aug 2018, 5:40 AM
CalviÕ²
CalviÕ² - avatar
0
CalviÕ² tanks man its work šŸ˜šŸ™
18th Aug 2018, 5:26 AM
M.akbari
M.akbari - avatar
0
CalviÕ² But why should I use onload here?
18th Aug 2018, 5:36 AM
M.akbari
M.akbari - avatar