Welcome to MSDN Blogs Sign in | Join | Help

Customizing Context Menu in Sharepoint

It’s been a while and I remember there are a number of ways to do this. This is the simple one…

The context menu itself is a JavaScript program and you can found it at \Program Files\Common Files\Microsoft Shared\web server extensions\60\TEMPLATE\LAYOUTS\1033\ows.js

There’s a script that out-of-the-box available to check whether there’s a customization applied.

if (typeof(Custom_AddDocLibMenuItems) != “undefined”)

  {

    if (Custom_AddDocLibMenuItems(m, ctx))

    return;

  }

 

So, the idea here is the override the Custom_AddDocLibMenuItems with our own script. You can add the script using the Content Editor Web Part, (you may want to clear the “Visible on The Page” option as it only contain our script. Choose the source editor and add this script to modify the context menu of Sharepoint.

<script language="javascript">
function Custom_AddDocLibMenuItems(m, ctx){
var strDisplayText = "Kirim melalui Email...";
 var strAction;
var strImagePath = "";
// parse the URL out of the itemTable
var URL = "";
var index = itemTable.innerHTML.indexOf("href=");
if (index > 0) {
  var str = itemTable.innerHTML.substr(index + 6);
  index = str.indexOf('"');
  if (index > 0)
  {
    URL = str.substr(0, index);
  }
}
if (URL != ""){  strAction = 'window.navigate("mailto:%20?subject=Take a look at this document...&body=<' + URL + '>")';

  // Add menu item 
CAMOpt(m, strDisplayText, strAction, strImagePath);
  // add a separator to the menu
  CAMSep(m); }
return false; }
</script>

The script only send the link of the document, you need to find the Jscript to attach the document as well. You can use the alternative and detailed documentation on customizing SPS is in Sharepoint Product & Technologies SDK (http://msdn.microsoft.com/library/en-us/odc_2003_ta/html/sharepoint.asp) and http://blogs.msdn.com/marioha/

 

_____________
Mario Hadiwinata MCSD, MCDBA, MCSE, MBS Certified Professional CRM  -  Partner Technology Specialist | Microsoft Indonesia
marioha@microsoft.com | (62-21) 2551-8176

Published Friday, February 17, 2006 3:45 PM by marioha

Comments

# re: Customizing Context Menu in Sharepoint

Wednesday, September 03, 2008 10:51 AM by djbenito90

it is possible to link a c# function instead of sending a mail ?

I've developped a code to reéférence my document. The function is called with the ItemAdded event.

It want to call it from the item context menu.

Can you help me ?

Anonymous comments are disabled
 
Page view tracker