So you want to start customizing a SharePoint page? Let’s say, you want to load or hide something in a page.
First steps include adding a content-editor-webpart on the page and adding some code on the source editor:
SharePoint provides the “_spBodyOnLoadFunctionNames” array. When the body is loaded, the onload event handler executes each function whose name is contained in this array. “FunctionName” was added to the array so that it would run when the body’s onload event fires.
At a client, this function was not called. Very weird problem, but we got a workaround really quickly from this blog
Adding an empty image on the page, and using the onload event of the image to start your code:
<img src="/_layouts/images/blank.gif" width="1" height="18" />
SharePoint already provides you with the blank image by default. Just add this line to you content-editor-webpart and add your function in the script tags.