SharePoint Hiding Menus (not using HideCustomAction)

Hiding SharePoint List and Library Menus
will find and hide the Explorer View menu:
"JavaScript"
 var doc = document.getElementsByTagName('ie:menuitem'); 
 for (var i = 0; i < doc.length; i++)
  {
    itm = doc[i];
    if (itm.id.match('OpenInExplorer')!=null)
      { itm.hidden=true; }
  } 

The trick here is to find the menu tags on the page. What we are looking for is this:
<ie:menuitem id="zz23_OpenInExplorer" ... hidden= ... />
The JavaScript starts by finding all tags named "ie:menuitem" and then looping through those to find the one we need. The hidden attribute is pretty obvious, so we set it to false.
For just one library:
Where do you put this JavaScript? For just one library use SharePoint Designer add this to the bottom of the allitems.aspx for that library. The best place is just before the end tag (</asp:Content>) tag of the "<asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server">" tag.
For all libraries:
To impact all libraries with a single edit you will need to use SharePoint Designer to add this JavaScript at the end of the Master Page (default.master), just before the "</BODY>" tag.
What about a Feature?
If you want to control the hiding of the menus by using a Feature so you can turn them on and off at will, and at the farm, application, site collection or site level the you have a little more work to do, but not too much.
I will return here later and add a full step by step, but here's the code you will need:
- A SharePoint Delegate control:
Add this to the bottom of your Master Page just before the </body> tag (The ControlId is up to you, but needs to match the Id used in the elements file):
<SharePoint:DelegateControl runat="server" ControlId="MiscControls" AllowMultipleControls="true"/>
- A .Net User Control:
HideMenus.ascx
<%@ Control Language="C#" ClassName="HideMenus" %> 
"JavaScript"
  var doc = document.getElementsByTagName('ie:menuitem'); 
  for (var i = 0; i < doc.length; i++)
  {
    itm = doc[i]; 
    if (itm.id.match('MultipleUpload')!=null | itm.id.match('OpenInExplorer')!=null) 
    { itm.hidden=true; }
  } 


- A feature file:
Feature.xml
<Feature
  Id="531F15CD-A646-45e5-AB61-4F8DF89C29D9"
  Title="Hide Menus"
  Description="Sample feature to hide selected menus (from TechTrainingNotes)"
  Scope="Web"
  Hidden="FALSE"
  xmlns="http://schemas.microsoft.com/sharepoint/"> 
 
  <ElementManifests>
    <ElementManifest Location="elements.xml" /> 
  </ElementManifests> 
</Feature>
- An elements file:
Elements.xml
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Control 
    ControlSrc="~/_controltemplates/HideMenus.ascx"
    Sequence="100"
    Id="MiscControls">
  </Control>  
</Elements>  
The is a list of items created by a typical WSS Master Page:


Menu item name

Menu

Menu text

PersonalInformation

The Welcome menu

My Settings

LoginAsDifferentUser

The Welcome menu

Sign in as Different User

RequestAccess

The Welcome menu

Request Access

Logout

The Welcome menu

Sign Out

MenuItem_Create

Site Actions

Create

MenuItem_Settings

Site Actions Site Settings
This is a list of items created by a typical document library allitems.aspx page:
(all of the above table plus the following)

New0 (zero, not O)

New

New Document (default click)

NewFolder

New

New Folder

Upload

Upload

Upload Document

MultipleUpload

Upload

Upload Multiple Documents

EditInGridButton

Actions

Edit in Datasheet

OpenInExplorer

Actions

Open with Windows Explorer

OfflineButton

Actions

Connect to Outlook

ExportToSpreadsheet

Actions

Export to Spreadsheet

ViewRSS

Actions

View RSS Feed

SubscribeButton

Actions

Alert Me

AddColumn

Settings

Create Column

AddView

Settings

Create View

ListSettings

Settings

Document Library Settings

DefaultView

View

All Documents (in typical library)

View1

View

Explorer View

ModifyView

View

Modify this view

CreateView

View

Create view

Comments