Friday, November 7, 2008

Embedding JavaScript in SharePoint Pages

The best method to embed custom javascript in SharePoint pages is to create a .js file and then include it in the SharePoint Page. If you would like to include javascript functions in the onload event of a sharepoint page, use the _spBodyOnLoadFunctionNames array. Include the push method in your script with the title of your function. The function should not include parameters...

<script>
function runOnLoad(){

}
_spBodyOnLoadFunctionNames.push("runOnLoad");
</script>

You found _spBodyOnLoadFunctionNames in C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\1033\INIT.JS

No comments: