This is in reference to SharePoint 2010.

I am writing some custom javascript that needs to know when the page has finished loading. To accomplish this I am pushing my callback function on to the _spBodyOnLoadFunctionNames array. This works great most of the time, but will sporadically fail and my handler will never get called.

Tracing it back, it looks like this array is never getting flushed because of issues with loading core.js.

In _spBodyOnLoadWrapper in init.js there is the call below which initiates the array being flushed. The ProcessDefaultOnLoad function is never getting called, and core.js does not show up as being loaded in the browser. The page appears to function just fine, but none of the functions in _spBodyOnLoadFunctionNames get called.

ExecuteOrDelayUntilScriptLoaded(ProcessDefaultOnLoad, "core.js");

Is _spBodyOnLoadFunctionNames the proper way to determine when a page has finished loading? Is there anything that would cause core.js not to be loaded?

A few more data points:

  1. I have only seen the issue in Chrome. With it being sporadic I can't say for sure that it never happens in other browsers.

  2. It appers to be happening more often after clearing the cache. Perhaps its a timing issue?


Where have you placed the content editor webpart???, Try palcing the CEW at the bottom of the page. I mean edit web part--> Layout--> Zone Index Change this to a different number so that the CEW appears on the bottom of the page


Have you tried using it together with the "_spBodyOnLoadCalled" variable?

if (!window._spBodyOnLoadCalled) {
} else {

It worked for me with this extra condition. I guess because the "_spBodyOnLoadFunctionNames" is a simple string array, nothing happens if you add your custom function's name in it after the _spBodyOnLoad event was handled.


Apparently this is a known issue with SP 2010 and Chrome.

http://withinsharepoint.com/archives/256 http://mosswell.blogspot.com/2013/06/sharepoint-2010-and-chrome-javascript.html


This is very old question but I faced same issue recently. I was loading my content editor webpart in a publishing page. When I publish my page I got same issue. If I load same content in site pages then it works great. SP.SOD.executeFunc is the solution in my case.

I used following code to solve the issue.

  SP.SOD.executeFunc('SP.js', 'SP.ClientContext',queryFunction);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.