Archive

Archive for April 22, 2009

Adding JavaScript function to SharePoint application pages

April 22, 2009 Chris Forbes Leave a comment

Hi there, just a quick and simple posting today. At some point you may need to call some custom java script when your page loads in SharePoint. To have your custom function called during the onLoad event simply add the _spBodyOnLoadFunctionNames.push method. to your script block

 

Sample script block added to your application page in SharePoint…

<script type="text/javascript">

_spBodyOnLoadFunctionNames.push(

"someFunction");

function someFunction() {

    alert(

"Hello world!)";

}

</script>

Categories: Uncategorized