Script error | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 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 ответов
+ 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