Auto start Javascript in SharePoint 2007 on page load

Wednesday, 15 April 2009 14:22 by myro

If you are trying to execute some Javascript code in a SharePoint 2007 page or in a custom Web Part, you need to attach your JavaScript function  to _spBodyOnLoadFunctionNames.push(). Here is an example on how to do it correctly:

<script type="text/javascript">
    
function startFunction()
{
// insert your javascript code
}
_spBodyOnLoadFunctionNames.push("startFunction");
</script>

The bad deal is that you are unable to add paramethers to your start function...

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:  
Categories:   SharePoint 2007
Actions:   Bookmark and Share | Permalink | Comments (2) | Comment RSSRSS comment feed
If you consider this post usefull for your purposes, please consider visiting my sponsors to help me out with the myrocode.com maintenance. Thank you.

Comments