We take pride in your success. We let our positivity drive us, day in and out. Talk to us at Mindfire to know us more.

Software Technology Tips

In SharePoint document Library/List we find menu items like New, Uploads, Actions and Settings etc. At times there might be requirements to rename these menu items for a specific site. The following Javascript function can be used to achieve the objective.

The code snippet shown below can be called from inside the specific SharePoint Page.
e.g AllItems.aspx page inside a Document Library/List.
 This javascript function needs to be called on Page load event using _spBodyOnLoadFunctionNames.push method.
 
<script language="javascript" type="text/javascript">
 
_spBodyOnLoadFunctionNames.push("renameMenuItem('New', 'My New')");
_spBodyOnLoadFunctionNames.push("renameMenuItem('Settings', 'My Settings')");
 
function renameMenuItem(oldMenuItemName, newMenuItemName)

{

    var vAnchorTag;

    var vAllAnchorTags = document.getElementsByTagName('a');



    if(oldMenuItemName.length!=0)

    {

        for (var j = 0; j < vAllAnchorTags.length; j++)

        {

            vAnchorTag = vAllAnchorTags[j];



            if (vAnchorTag.innerText.indexOf(oldMenuItemName)!=-1)

            {

                 vAnchorTag.innerText = newMenuItemName;

                 try

                 {

                     if(newMenuItemName.length != 0)

                     {

                                vAnchorTag.parentNode.previousSibling.firstChild.firstChild.alt
= newMenuItemName;

                     }

                     else

                     {

                                vAnchorTag.parentNode.previousSibling.firstChild.firstChild.alt
= oldMenuItemName;

                     }

                 }

                 catch(err)

                 {

                 }

            }

        } // End For

    } // End If

}// End Function 
 
</script>


Related Tags:

SharePoint

Author: Samarendra Swain

top

Related Pages

  • SharePoint Development Gurus
  • SharePoint Custom Projects

SharePoint

Let us Connect!

privacy

copyright (c) Mindfire Solutions 2007-2012. Login