not the last of his kind
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.
| Print article | This entry was posted by denni on July 8, 2008 at 6:31 pm, and is filed under Programming, Software. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |
about 1 year ago
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)
about 1 year ago
Hi vidurasai,
Please make sure you checkin and publish your page after making the changes.
about 1 year ago
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 ;-(
about 1 year ago
hi.. im trying to add context menu item to old sites and home..plz advise..
about 1 year ago
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
about 1 year ago
Hi Mark, Sean,
Make sure to place the Content Editor Web Part as the last web part in the page.
about 1 year ago
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?
about 1 year ago
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.
about 1 year ago
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.
about 1 year ago
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.
about 10 months ago
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) {};
}
about 8 months ago
@Mark Deraeve
@Sean
@Davis
try this:
window.onload = function() {
AddSendSubMenu = function (m,ctx) {
}
}
about 8 months ago
blog delete automatically lines with “”.. insert
script type=”text/javascript”
before the code and
/script
after the code with “”
about 8 months ago
Excellent resources for me!
Thanks for everybody!
about 7 months ago
How do I fing the property name so I can do this for other properties like Edit Properties or others
about 4 months ago
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
about 4 months ago
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.
about 4 months ago
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.
about 4 months ago
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.
about 4 months ago
Hi,
No luck. The javascript is just being completely ignored.
about 4 months ago
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?
about 4 months ago
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.
about 3 months ago
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