Monday, May 16, 2011

_spbodyonloadfunctionnames is undefined Javascript Error in sharepoint

Generally, ASP.NET 2.0 Master page concept is used for sharepoint pages and the “body ” is defined in master page. So, the content page is not able to add function to the body’s onload event directly. In order to work around this limitation, SharePoint provides the “_spBodyOnLoadFunctionNames” array. When the body is loaded, the onload event handler executes each function whose Name is contained in this array. We added “myFunction” to the array so that it would run when the body’s onload event fires.
_spBodyOnLoadFunctionNames.push("myFunction ");
To fix the javascript error: View source of sharepoint page from browser.
1. Make sure in the head tag, init.js is included.


2. Body onload is properly defined.


If these are not defined then it causes javascript error.
Hope, It helps.

1 comment:

Shijuse said...

http://social.msdn.microsoft.com/Forums/en-US/tfsadmin/thread/a49a0d9d-3561-4553-b6b6-a4c5183639a7
This is the issue am facing now .please share your ideas on this

Thanks in advance

shiju