Adding JavaScript to Execute on SharePoint Page’s Body Onload Event

The SharePoint master page contains the <body> element.

SharePoint provides the “_spBodyOnLoadFunctionNames” array.

When the SharePoint page’s body is loaded, the onload event handler executes each function whose name is contained in this array.

You can add “ MyFunctionName” to the array and it will run when the body’s onload event fires.

<script language="javascript">
_spBodyOnLoadFunctionNames.push("MyFunctionName");
function MyFunctionName()
 {
 // Code
 }
 </script>

http://blogs.msdn.com/b/sharepointdesigner/archive/2007/06/13/using-javascript-to-manipulate-a-list-form-field.aspx

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s