Recently my customer asked me to do something I generally do not approve of - changing the basic behavior of a SharePoint document library.
I usually for maintaining a solid user experience and believe it is one of the many strong point SharePoint has to offer by giving the user a familiar environment throughout his LOB systems - if it’s a team workspace, an internal organization portal or (new in 2007) the organization internet portal.
Well, with all that said - one of my customers still insisted on removing the "new" document menu item from all the document libraries and allowing only to "upload" documents...
Like a good SharePoint-boy I immediately thought my solution will be creating a new feature that uses the
To my surprise I learned that the “new” menu item in the list view web part tool bar is not listed as a
Finding no other choices, I created this JS code in a separate JS file and referenced it from all master pages involved…
If checks if the current page has a document library view and if so – locate and hide its “new” menu item…
Just add it to your page, and call HideNewDocumentMenuItem on body’s load:
if( ctx )
if( ctx.listBaseType == 1 )
var tables = document.getElementsByTagName("table");
for(var i=0; i< tables.length; i++)
if( tables[i].id.indexOf("NewMenu") > 0 )
var elm = tables[i];
Hope this helps you guys,
If you have a more elegant solution – please post a comment… I’ll be happy to hear.
Shai Petel (Ben Shooshan).