Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Introducing JavaScript Finishing the Game Adding New Graphics

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,867 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
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

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,867 Points

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

I appreciate the help!