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:
- Go to the document’s view url, for example:
http://example.com/Documents/Forms/AllItems.aspx. - 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.
- 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.
- 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.
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)
Hi vidurasai,
Please make sure you checkin and publish your page after making the changes.
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 ;-(
hi.. im trying to add context menu item to old sites and home..plz advise..
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
Hi Mark, Sean,
Make sure to place the Content Editor Web Part as the last web part in the page.
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?
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.
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.
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.
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) {};
}
@Mark Deraeve
@Sean
@Davis
try this:
window.onload = function() {
AddSendSubMenu = function (m,ctx) {
}
}
blog delete automatically lines with “”.. insert
script type=”text/javascript”
before the code and
/script
after the code with “”
Excellent resources for me!
Thanks for everybody!
How do I fing the property name so I can do this for other properties like Edit Properties or others