RSS Feed

SharePoint Bending: Remove “Send To” Context Menu Without Modifying Core.JS

Posted on Tuesday, July 8, 2008 in Programming, Software

This is becoming a pretty common requirement. Some people just don’t want the “Send To” menu appearing in the context menu of the document library. You can do it — customize the SharePoint context menu by — by simply making some modification in core.js as suggested by many.

But modifying SharePoint core files should not be done, because your modifications can be overwritten by future SharePoint updates. So here’s a little trick to remove the “Send To” context menu without modifying core.js:

  1. Go to the document’s view url, for example: http://example.com/Documents/Forms/AllItems.aspx.
  2. If it is a web part page, edit the page and add a Content Editor web part. Otherwise you need to edit that page in SharePoint Designer.
  3. Open the source editor (not the rich editor) for the Content Editor web part, or open the code view (not the design view) of that particular page in SharePoint Designer.
  4. Either inside the web part or the code view, insert the following script:


    <script type="text/javascript">
    AddSendSubMenu = function (m,ctx) {}
    </script>

That script will redefine the AddSendSubMenu() function with a new implementation. Since the function body is empty, it simply won’t display anything, thus the “Send To” context menu is removed from the context menu.

You can do this on some pages manually, or if you want to apply this to all pages, just insert the code to your master page.

Bring on the comments

  1. vidurasai says:

    hi
    i worked as u explained but its not working fine, on doc library i have created content editor webpart & pasted the java script in source editor, only once its not displaying the ‘Send to’ option & when i go to home page & come back to doc lib then again i can able to see the ‘Send to’ option i.e again displaying……….its not working in designer toooo, when i have pasted in code of designer then its throwing an error(i.e., its displaying full java script code again in error, saying parser error)

  2. denni says:

    Hi vidurasai,

    Please make sure you checkin and publish your page after making the changes.

  3. Mark Deraeve says:

    I tried your solution, adding a content editor webpart.
    It works at first, but when I sign out and sing in as a different user, it doesn’t work. I have publisching disabled and just preseed exit edit mode. When I log back in with the first user, the send menu is back. In the source I see the javascript, but still it won’t work ;-(

  4. shady says:

    hi.. im trying to add context menu item to old sites and home..plz advise..

  5. Sean says:

    This only works when you first add the web part. If you leave the page and then go back in, the ‘Send To’ is back

  6. denni says:

    Hi Mark, Sean,
    Make sure to place the Content Editor Web Part as the last web part in the page.

  7. Michael Geary says:

    Cool!! I have this working using the Content Editor Web Part. However I cannot get this working when added to a Master Page. Where should it be added? Inside the Head tag, the Body tag, or somewhere esle?

  8. denni says:

    Hi Michael,
    You have to make sure that the code is executed after the web part that loads the menu. Hence, in the master page, you can put it just before the closing body tag.

  9. David says:

    Sean is right. This only works the first time. On log out and refresh, the menu comes back. Yes I placed the content web part last.

    This doesn’t work.

  10. HMB says:

    I haven’t tried this yet, but been looking for it for a while. Great tip! Is there any easy way to hide/show the “Send To” based on user group? I want some groups to have it, others not.

    Thanks.

  11. jim says:

    Nice. Clever work around, but it needs to be invoked properly. Using the code suggested above, here’s what I added to my page and it works consistently:

    _spBodyOnLoadFunctionNames.push(”resetAddSendSubMenu()”);

    function resetAddSendSubMenu(){
    AddSendSubMenu = function (m,ctx) {};
    }

  12. Marco Valli says:

    @Mark Deraeve
    @Sean
    @Davis

    try this:

    window.onload = function() {
    AddSendSubMenu = function (m,ctx) {
    }
    }

  13. Marco Valli says:

    blog delete automatically lines with “”.. insert

    script type=”text/javascript”

    before the code and

    /script

    after the code with “”

  14. james zheng says:

    Excellent resources for me!

    Thanks for everybody!

  15. David Lewis says:

    How do I fing the property name so I can do this for other properties like Edit Properties or others

Leave a Reply