+ 9

How to use window.onload in JavaScript

Whenever I use window.onload it acts really weird --It don't work when I use a function inside it but sometimes it do work atleast in other people's code What's the right way to use it ?

19th Feb 2017, 8:07 AM
Utkαrsh
Utkαrsh - avatar
1 Answer
+ 15
window.onload = func; <-- correct window.onload = function(){func();}; <-- correct window.onload = func(); <-- wrong
19th Feb 2017, 9:22 AM
Valen.H. ~
Valen.H. ~ - avatar