Jean Paul's Blog

There are 2 types of People in the World, One who Likes SharePoint and..

  • Microsoft MVP

  • MindCracker MVP

  • CodeProject MVP

  • eBook on SharePoint 2010

  • eBook on Design Patterns

  • eBook on Windows Azure

  • NLayers Framework @ CodePlex

  • MSDN Forums

  • .Net vs. Java

    Due to Public Demand

Hide Version History in SharePoint 2010

Posted by Jean Paul on October 3, 2013

In this article I would like to take you through a Real World Scenario. You wanted to hide the Version History menu item from the documents menu.


I am working on original code of Matthew Yarlett for the original code. Thank You Matthew for making things easier.

HideAction won’t work!

The typical HideAction way of hiding ribbon items won’t work with context menu items as they are rendered through JavaScript.

JavaScript Approach

The Version History menu item is residing in the Edit Control Block group of menu items. These menu items are rendered through the core.js java script file. The file resides in the _layouts folder.

We need to visit the file to find the Version History text & sequence number. The sequence number determines the position of menu item in the edit control block.

The file can be located in folder:

C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions14TEMPLATELAYOUTS

Opening the core.js file & locating Version History text & use the L_Versions_Text variable to look ahead in file & locate the sequence number as 800.


JavaScript Code

Following is the JavaScript code which perform the hiding functionality.

ExecuteOrDelayUntilScriptLoaded(editEcbMenusEx, ‘Core.js’);

function editEcbMenusEx() {

try {

if (typeof ctx == “undefined”) {



else {


var css = ‘li[sequence=”800″]{display:none;}’;

var head = document.getElementsByTagName(‘head’)[0];

var style = document.createElement(‘style’);

style.type = ‘text/css’;

if (style.styleSheet){ style.styleSheet.cssText = css; }

else { style.appendChild(document.createTextNode(css)); }



} catch (e) {



Please note that the script is executed after Core.js is loaded.

How to test the code?

For testing the code, you need to perform the following steps:

1. Create a HideHistory.js file with above content & upload to Site Assets library

2. Edit the library page & add a content editor web part

3. Point the web part to our HideHistory.js file


4. Refresh the page

5. See the Version History menu item is hidden now



Please note that the hiding takes place in all libraries & lists where the content editor is placed. You need to add if condition to check for list template OR list name for conditional hiding.

If you need to apply to all pages without using Content Editor web part, you can add the code to master page. Please visit this link on how to do it.



In this article we have explored the way to hide Version History menu item in libraries.

The source code is attached here with.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s