Source: http://www.cnblogs.com/ycc/archive/2007/10/29/942223.html
Use JavaScript to customize SharePoint Document Library/list item menu
Custom menus in SharePoint are usually implemented by feature with customaction, for example, hiding a menu:
< Hidecustomaction >
Groupid = "text"
Hideactionid = "text"
Id = "text"
Location = "text">
</ Hidecustomaction >
Customize a menu:
< Customaction
ID = "Extend"
Location = "Microsoft. Sharepoint. Administration. applicationmanagement"
Sequence = "10"
Title = "Extend or upgrade virtual server"
Description = "" >
< Urlaction URL = "Vslist. aspx? Nextpage = extendvsoption. aspx & amp; show = needextend & amp; show = needupgrade" />
</ Customaction >
For more information, see the SDK or related online.Article.
But .... This method does not work. For example, if I want to change an item in the menu of the document library or listitem in the list or add or delete a menu, this method will not work ......
At this time, it is very easy to implement through javascript. If you have read the core. jsCodeWe will find that Ms has reserved custom interfaces for us to implement our own menu definition. What Ms wants is thoughtful ......
Core. JS in the path C:/program files/common files/Microsoft shared/Web Server Extensions/12/template/layouts/Under 1033 [English] Or 2052 [Chinese, find the function for adding the document library/list menu.
As you can see, We can customize custom_adddoclibmenuitems (Document Library)/custom_addlistmenuitems (list) to add our own menus. The specific method is...
1) Add a webpart-Content Editor widget to our page and modify the widget attributes. It is best to set the widget to hidden:
Click "Source editor..." And enter our custom Javascript script to implement our own menu:
< Script Language = " Javascript " >
Function Custom_adddoclibmenuitems (M, CTX)
{
Strdisplaytext = " My menu " ;
VaR Rootmenu = Casubm (M, strdisplaytext, "" , "" , 500 );
Strdisplaytext = " My menu or my menu " ;
Straction = " Stsnavigate ('HTTP: // www.cnblogs.com ') " ;
Strimagepath = CTX. imagespath + " Oisweb.gif " ;
Menuoption = Camopt (rootmenu, strdisplaytext, straction, strimagepath );
Menuoption. ID = " Id_mysubmenu " ;
Return False ;
}
</ Script >
For details about how to write a function, refer to the core. js statement: Return false at the end. This indicates that the system code will continue to be executed, if return true... The entire menu is just your own menu item. Save the file and exit the editing mode:
if I want to remove a menu, such as workflow, I am stupid. I used a stupid method to copy the script in his built-in adddoclibmenuitems, comment out the menu items to be removed, and return true at last.
personal habits: