locked
_spBodyOnLoadFunctionNames.push & ExecuteOrDelayUntilScriptLoaded undefined. RRS feed

  • Question

  • Hi Experts,

    I started learning share point 2010.

    I tried to execute some java script but I am getting undefined error .

    //_spBodyOnLoadFunctionNames.push("pageOnLoad");
     ExecuteOrDelayUntilScriptLoaded(pageOnLoad,'sp.js');

    I tried both functions but it is showing error.

    Can you please tell how to execute it.

    Thanks


    AshisK

    Friday, December 20, 2013 12:08 PM

Answers

  • Hi,
    According to your post, my understanding is that you want to use JavaScript Client Object Model in SharePoint 2010.

    We can try to use the following code by adding it into a Content Editor Web Part:

    <script language="ecmascript" type="text/ecmascript">
    ExecuteOrDelayUntilScriptLoaded(pageOnLoad, "sp.js");   
    function pageOnLoad() {
        alert("Hello World!");
    }
    </script>

    If the issue still exists, please check whether you have registered the sp.js library and provide you code.
    More information:
    http://msdn.microsoft.com/en-us/library/office/ff411788(v=office.14).aspx

    Best Regards


    Dennis Guo
    TechNet Community Support

    • Marked as answer by Ashis_K Monday, December 23, 2013 12:42 PM
    Monday, December 23, 2013 7:14 AM
  • Hi Dennis,

    Thanks for the reply.

    Now I am able to execute the code.

    Can you post some code or link to count the items inside a list.

    Thanks in advance


    AshisK

    • Marked as answer by Ashis_K Monday, December 23, 2013 12:42 PM
    Monday, December 23, 2013 12:42 PM

All replies