my aim is to add a Ribbon Button which is opening a printing dialog for a selected file in a document library. I already added the Button with SP Designer and linked it with a html file which is calling the js.

The function printFile is called by the Ribbon.

function printFile() {
        //throws error
        ExecuteOrDelayUntilScriptLoaded(start, "sp.js");

function start() {
    var ctx = SP.ClientContext.get_current();
    var items = SP.ListOperation.Selection.getSelectedItems(ctx);
    var selectedItem = '';
    var itemURL;
    for (index in items) {
        //only for testing

When running i got this error:

The value of the property "ExecuteOrDelayUntilScriptLoaded" is null or undefined, not a Function object

Any idea to solve this error?

2 Answers 2



ExecuteOrDelayUntilScriptLoaded(start, "sp.js");


SP.SOD.executeOrDelayUntilScriptLoaded(start, "sp.js");

Reference: http://msdn.microsoft.com/en-us/library/ff411788(v=office.14).aspx

  • also an error: "SP is undefined"
    – mbauer
    May 7, 2013 at 6:50
  • is this document library web part on some custom application page ? it is obvious that you have issue with reference to sp.js ... core sharepoint Javascript client object model cannot be called from .html page if this is what you are trying .. for anything else you would have to write custom web service .. try adding this .. <script type="text/ecmascript" src="/_layouts/SP.Core.js"></script> May 7, 2013 at 7:15
  • didn't work. it is a standard document library on a site. is there another way to access the sp.js. i only have visual studio 2012 web express and no direct access on the sp server.
    – mbauer
    May 7, 2013 at 7:42
  • 1
    sp.js should be loaded by default in SP2010. So you do probably not need the ExecuteOrDelay there, since its executed when a user clicks it. By then everything should be loaded May 7, 2013 at 7:52
  • you should describe all the steps you took .. where you put this code .. i tried your code and it works .. May 7, 2013 at 8:45

can you please try This link .

Please update if working as I am also facing same challenge.
My developement: using VS 2010 add ribbon button as a feature and call Javascript. refer This Link


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.