JavaScript Introducing JavaScript Finishing the Game Adding New Graphics

Franklin Rony Cortez Barrera
Franklin Rony Cortez Barrera
3,064 Points

window.onload its a keyword or a function?

I dont understand why window.onload execute when the web page load.

2 Answers

Zac Mazza
Zac Mazza
5,866 Points

Would you be able to post the code in question?

window.onload is an event, and is similar to the document.onload event. These events fire the code or method contained within when the entire document loads, including content.

Here's a good example I found on StackOverflow for further reading: https://stackoverflow.com/questions/20180251/when-to-use-window-onload

Jennifer Nordell
Jennifer Nordell
Treehouse Moderator

Hi there, Zac Mazza. I took the liberty of changing your comment to an answer. This means that the question will show up as answered on the forums and also make your answer eligible for voting and possible selection of "Best Answer". Thanks for helping out in the Community! :sparkles:

Zac Mazza
Zac Mazza
5,866 Points

Thanks Jennifer! I'll have to pay closer attention when commenting. :-)

I appreciate the help!