Sunday, July 8, 2007

Calling a Custom Javascript Function on Page Load

A simple way to add a custom Javascript function to the list of scripts that run at page load is as follows:
<script type="text/javascript">
_spBodyOnLoadFunctionNames.push("YourFunctionName");
</script>

1 comment:

Cindy said...

I've been seeing this example or one similar on many blogs but am having issues getting it to work. It seems as my code is not getting executed and I think it has to do with where I am putting the call to _spBodyOnLoadFunctionNames. Could you provide a more detailed sample showing exactly where I should put this call? Thanks!!