function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
oldonload();
func();
}
}
}
addLoadEvent(nameOfTheDesiredFunctionToBeCalled);
function nameOfTheDesiredFunctionToBeCalled()
{
//function definition here
}
---------------------------------------------------------------------------
For calling on body pageload simply add the code on body tag
<body onload="theDesiredFunction()">
----
----
</body>
A blog for IT related posting especially software and web development. Focus will be given to the latest technologies. Your valuable comments are highly appreciated.
Wednesday, March 3, 2010
Adding JavaScript function on PageLoad event in ASP.NET
Sometimes we need to call a specific javascript function during the pageload. We can call the function on the body onload event. However, sometimes we cannot define body especially when we use Master/Content pages. Then we can call the function using the following code sequence.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment