Why if we don't use the window.onload function in JavaScript the innerHTML cant work? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Why if we don't use the window.onload function in JavaScript the innerHTML cant work?

I have some problem here, why if we use window.onload in javascript the innerHTML is executed, but if i am not use window.onload the innerHTML was not executed?? Ex : https://code.sololearn.com/WEXTh9iiw4se/?ref=app

2nd Jan 2021, 1:03 PM
Yadi
Yadi - avatar
13 Answers
+ 5
That is because you must include your .js file in your .html file for any JavaScript to work. The window.onload function helps you do that indirectly here. So your .js is executed that way after the page is loaded. Or you can do this to achieve the same. Just click on "Text" to see it change. https://code.sololearn.com/WpZSI5kwoQXr/?ref=app Read this for clarity. https://www.sololearn.com/post/7444/?ref=app
2nd Jan 2021, 2:51 PM
Avinesh
Avinesh - avatar
+ 2
Wtf man?
2nd Jan 2021, 1:06 PM
Yadi
Yadi - avatar
+ 2
Would you stop it
2nd Jan 2021, 1:06 PM
Lisa :)
Lisa :) - avatar
+ 2
I don't know how
2nd Jan 2021, 1:07 PM
Yadi
Yadi - avatar
+ 2
He's done it to me too, I've reported their account as I believe it could be fake
2nd Jan 2021, 1:07 PM
Lisa :)
Lisa :) - avatar
+ 2
Oh sorry I didn't mean you Yadi I meant that Nicholas guy
2nd Jan 2021, 1:08 PM
Lisa :)
Lisa :) - avatar
+ 2
Hope the bot is gone.
2nd Jan 2021, 1:09 PM
Yadi
Yadi - avatar
+ 2
Ya me too
2nd Jan 2021, 1:09 PM
Lisa :)
Lisa :) - avatar
+ 1
That guy's account has been block
2nd Jan 2021, 1:13 PM
Lisa :)
Lisa :) - avatar
+ 1
Haha nice
2nd Jan 2021, 1:14 PM
Yadi
Yadi - avatar
+ 1
Well how with my question ๐Ÿ˜
2nd Jan 2021, 1:14 PM
Yadi
Yadi - avatar
+ 1
I'm not sure I started using SoloLearn again yesterday I haven't been coding in the last few months, sorry I couldn't help๐Ÿ˜”
2nd Jan 2021, 1:16 PM
Lisa :)
Lisa :) - avatar
0
No problem bro
18th Jan 2021, 12:36 PM
Yadi
Yadi - avatar