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

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.

  • vidurasai

    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)

  • denni

    Hi vidurasai,

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

  • http://www.dailycode.net Mark Deraeve

    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 ;-(

  • http://secure shady

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

  • Sean

    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

  • denni

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

  • Michael Geary

    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?

  • denni

    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.

  • http://TotalWaster David

    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.

  • HMB

    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.

  • jim

    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) {};
    }

  • http://vallimarco.spaces.live.com/ Marco Valli

    @Mark Deraeve
    @Sean
    @Davis

    try this:

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

  • http://vallimarco.spaces.live.com/ Marco Valli

    blog delete automatically lines with “”.. insert

    script type=”text/javascript”

    before the code and

    /script

    after the code with “”

  • james zheng

    Excellent resources for me!

    Thanks for everybody!

  • David Lewis

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

  • Jeni

    Hi,

    In sharepoint designer code view, where is the best place to insert the extra code:

    _spBodyOnLoadFunctionNames.push(”resetAddSendSubMenu()”);

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

    Thanks

    Jeni

  • denni

    Hi Jeni,

    You can insert it immediately before the closing </head> tag.

    Don’t forget to wrap the JavaScript code inside the <script type=”text/javascript”></script> tag.

  • Jeni

    Help!

    Really sorry but I can’t get this to work at all on MOSS.

    I have put the following just before the tag in my master page:

    _spBodyOnLoadFunctionNames.push(”resetAddSendSubMenu()”);

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

    But it doesn’t work at all. Do you have any ideas as to why this wouldn’t work? I really need to disable the Send to for a client site.

  • denni

    Hi Jeni,
    If you have a problem and can edit the master page, try to put the original script:
    <script type=”text/javascript”>
    AddSendSubMenu = function (m,ctx) {}
    </script>
    near the end of your master page, just before the </body> tag.

  • Jeni

    Hi,

    No luck. The javascript is just being completely ignored. :-(

  • Jeni

    I have just tested this on another server and it works great.

    I was originally trying it on an extranet server. Is there anything that you know of in the security setup that would block this code?

  • denni

    The code shouldn’t be blocked since it’s embedded, not linked to an external resource.

    Maybe you can check the HTML source (using the View Source menu) and see whether the code is rendered properly.

  • http://www.sharepointkb.net Yavuz B.

    Hi, great code. Works fine! But i have one more question:

    Is it possible to deactivate:

    – filtering
    – sorting,
    – and the complete ECB?

    thank you, best regards
    yavuz

  • http://www.Areeza.com Hussain Naqvi

    Try this, I have called twice in javascript:
    1 . simply called AddSendSubMenu
    2. I have pushed reset OnLoad

    AddSendSubMenu = function (m,ctx) {}
    _spBodyOnLoadFunctionNames.push(“resetAddSendSubMenu()”);

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

  • http://www.Areeza.com Hussain Naqvi

    Here is exact syntax:
    copy and paste in content editor webpart. Make sure your content editor webpart is the last webpart in page.

    AddSendSubMenu = function (m,ctx) {}
    _spBodyOnLoadFunctionNames.push(“resetAddSendSubMenu()”);

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

  • http://Website Mota Landh

    I just want to remove “Download a copy” from the sub menu. I like leave everything else intact.

  • http://Website DT

    Is it possible to only disable the Send-To Other Location option ?
    Assuming so – please can someone offer the code for this, thanks in advance

  • Lonneke

    Is it possible to add “open with explorer” to the document ribbon/context menu on a similar way?

  • nandy

    hi,

    thanks :)

  • german

    TANKS!!!!! WORK GREAT

    A[id$=’Ribbon.Documents.Copies.Download-Large’] {
    DISPLAY: none
    }

    AddSendSubMenu = function (m,ctx) {}
    _spBodyOnLoadFunctionNames.push(“resetAddSendSubMenu()”);

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