Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
When I used window.onload=function_name() where function_name is a java script function, the function did not get executed. But it works fine when I use window.onload=function_name.
window.onload=function_name() calls the function function_name and sets the onload handler to its return value.
window.onload=function_name()
function_name
onload
window.onload=function_name sets the handler to the function itself, so function_name will be called when the onload event occurs.
window.onload=function_name
Add a comment
window.onload=function_name;
This will be executed as expected when windows loading finished, while this one:
window.onload=function_name();
Will be executed when browser reaches that point and the value for the function will be returned to the window.load after page loaded.
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.