A slightly better approach than <body onload="…">

by Yang Yang on February 5, 2009

Share This Article:
Subscribe to Kavoir: blog feed

A tiny little quick tip for javascript beginners.

While you still can execute javascript code upon page loading completion with:

<body onload="jsFunc();">

You can just attach or define an onload event to body in the normal code flow:

window.onload = function() {
	jsFunc();
}
Share This Article:
Subscribe to Kavoir: blog feed

You should also read:

Leave a Comment

Previous post:

Next post: