jQuery and SharePoint – Hiding Welcome Menu Items

One of the requirements I have run across a few times is to remove one or more menu items from the SharePoint 2007 welcome menu.   One quick and easy way to accomplish this task without server side code and/or modifications to SharePoint system files (never recommended) is to use jQuery. 

Using jQuery you can easily accomplish this task with just a few lines of code.   Below I am registering the javascript function HideControls with SharePoint so that the function is automatically called upon page load.    The HideControls function uses JQuery to locate the menu nodes and remove them.  As you can see this is being accomplished by using the jQuery method replaceWith and passing in an empty string.

This script which is placed in a custom SharePoint master page will hide the Login as a Different User, Request Access, and Logout menu items from the Welcome menu.    Don’t forget that someplace in the <head> section of your master page you need a script reference to the jQuery .JS file.   This sample was tested with version 1.3.2 of jQuery.

<Script>

_spBodyOnLoadFunctionNames.push("HideControls");





function HideControls() {
jQuery.noConflict();
jQuery("*[id*='_LoginAsDifferentUser']").replaceWith("");
jQuery("*[id*='_RequestAccess']").replaceWith("");
jQuery("*[id*='_Logout']").replaceWith("");
}

</Script>

With a little bit of jQuery it is possible to make minor UI adjustments to SharePoint  to meet your needs.

Leave a Reply