Pages

Search This Blog

Sunday, July 10, 2011

Call javascript on page load

If you have scenario where you want to call javascript function on the page load event in sharepoint, you can use " _spBodyOnLoadFunctionNames" method. Add the following line of code in the page/control design.

_spBodyOnLoadFunctionNames.push('FunctionName');

function FunctionName()
{
alter('Test');
}

2 comments:

  1. Hi, can we call two javascript function using this method ?At present I am not able to, if yes then please suggest the right way to do so.

    Cheers,
    Amiya

    ReplyDelete
    Replies
    1. Hi Amiya, to accomplish this, you can create a javascript function say "ExecuteMultipleFunctions" and call multiple functions inside this function. Then you can easily suffice your requirement of calling multiple function on page load by calling this single function on "_spBodyOnLoadFunctionNames"

      Delete