I'm working on customizing the context menu [(...)-menu] of a document library. In line 5 of my code I'm trying to give a link to my new inserted entry of context menu, but the code seems wrong and doesn't work. I would be thankful, if someone of you knows the right code for linking.

<script language="javascript">
        function Custom_AddDocLibMenuItems(m, ctx)
          var strDisplayText = "Say Hello World!";
          var strAction = strDisplayText.link("MY LINK");
          var strImagePath = "";

          // Add our new menu item
          CAMOpt(m, strDisplayText, strAction, strImagePath, strDisplayText.link);

          // add a separator to the menu

          // false means that the standard menu items should also be rendered
          return true;

Additional question: Does somebody know, how to add new items to this code? What kind of "tag" they need?

Thank you very much in advance.

1 Answer 1


There are two ways to add this functionality. You can use Custom Action if you don't want to conditionally add the menu, so the menu will appear always for all users, as seen here

If you want to conditionally add the item, then you would use code similar to the one you posted. In this case, the 3rd parameter should point to a JavaScript function. See this post

  • Thanks for your help. It's hard for me to see what u mean by your second link. Can you explain what u mean with 3rd parameter and how it might look like? I'm a bit lost on the sites u linked, although they refer to my topic :(
    – SteffPoint
    May 20, 2016 at 9:49
  • Hi @SteffPoint, this function CAMOpt(m, strDisplayText, strAction, strImagePath, strDisplayText.link); takes parameters, the third one which is strAction, should point to a function like "doFunction('anything')", or in the case of the post I sent you, he's using an alert like: "alert('Hello world')" May 20, 2016 at 22:36

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.