+ 1

Why after I created the second script code the first stopped working? (JavaScript)

https://code.sololearn.com/Wyea5vS6Uj1I/?ref=app

8th Oct 2020, 7:04 AM
Karak10
Karak10 - avatar
2 ответов
+ 2
You are overwritting value of `window.onload` property. If you want to add multiple EventListeners use addEventListener() method. window.addEventListener('load', function f1(){ //code for f1 }); window.addEventListener('load', function f2(){ //code for f2 });
8th Oct 2020, 7:08 AM
🇮🇳Omkar🕉
🇮🇳Omkar🕉 - avatar
+ 1
🇮🇳Omkar🕉 thanks, SoloLearn should had explained these stuff in the course, they just dropped the window.onload event there without explaining anything.
8th Oct 2020, 9:56 AM
Karak10
Karak10 - avatar