Window Onload!!!!! | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Window Onload!!!!!

My JavaScript "Math Code" was not working , I searched for the problem and I came across with "window.onload = function ()", It solved my error. But I wanted to know what it's about and why it's used , I Googled it but the answer were going above my head , can anybody explain it in a simpler way😅😅😅😅?????????

29th Jul 2020, 7:51 AM
_Levi_
_Levi_ - avatar
4 Answers
+ 3
_K_ think of each time you wake up you start / see something ... when you window.onload you wake up the program...
29th Jul 2020, 7:57 AM
BroFar
BroFar - avatar
+ 1
Ok BroFar , that's window.onload work , btw thanks for the answer , and it's really a easy to understand answer..........
29th Jul 2020, 8:10 AM
_Levi_
_Levi_ - avatar
+ 1
It is used to command js to load after html and css. If It isn't done so js will run first and if you have access any element in it .it will not get your element as js loaded before html hence throw an error as ...... can't set property of null in line **
29th Jul 2020, 9:18 PM
Divya Mohan
Divya Mohan - avatar
+ 1
Divya Mohan thanks brother
30th Jul 2020, 3:47 AM
_Levi_
_Levi_ - avatar