How to hide the Site Actions drop down list using JavaScript

When you normally open SharePoint 2010 you will find the Site Action drop down list on the top left:

This post will demonstrate how to hide the Site Actions drop down list using JavaScript.
First, create an empty SharePoint solution using VS and then add a custom action:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="">

The ControlClass is defined as follows:

namespace HideSiteActions
public class SiteActionAddPoint : Control
protected override void OnPreRender(EventArgs e)
bool HideSiteActions = true;
//check permissions to set HideSiteActions to false or true.
//HideSiteActions = //SPContext.Current.Web.DoesUserHavePermissions(SPBasePermissions.FullMask);
if (HideSiteActions)
string JSKey = "JSHideSiteActions";
Type JSType = this.GetType();
string JScript = string.Format("document.getElementById('siteactiontd').style.display = 'none';");
if (!this.Page.ClientScript.IsStartupScriptRegistered(JSType, JSKey))
this.Page.ClientScript.RegisterStartupScript(JSType, JSKey, JScript, true);

Use the “OnPreRender” function to render this java script code: (“document.getElementById(‘siteactiontd’).style.display = ‘none’;”), to hide the Site Actions drop down list.
The variable “HideSiteActions” is used to control Site Actions drop down list’s hide/show based on permissions.

After deploying this feature to SharePoint, refresh your page and the Site Action drop down list will be hidden.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.