2

Can we use ExecuteOrDelayUntilScriptLoaded in application pages. If yes, do I need to add sp.js to the project to make it work?

2 Answers 2

7

Since SP.SOD.executeFunc supports on demand scripts, but SP.SOD.executeOrDelayUntilScriptLoaded does not, I would recommend to use SP.SOD.executeFunc with CSOM:

SP.SOD.executeFunc('sp.js', 'SP.ClientContext', function() {
    var clientContext = SP.ClientContext.get_current();
    console.log(clientContext.get_url());
});
1
  • 1
    this one worked for me Mar 19, 2014 at 12:34
6

ExecuteOrDelayUntilScriptLoaded is a method used to delay a function call unless a particular script is loaded. Yes, you can use it in application page. If you are using CSOM you need to add a reference to sp.js file.

You can also use SP.SOD.executeFunc if you are using on demand scripts.

A very good article on this is here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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