{"id":5554,"date":"2013-06-18T14:51:06","date_gmt":"2013-06-18T06:51:06","guid":{"rendered":"http:\/\/www.boostsolutions.com\/blog\/?p=5554"},"modified":"2023-07-31T11:38:54","modified_gmt":"2023-07-31T03:38:54","slug":"how-to-hide-the-site-actions-drop-down-list-using-javascript","status":"publish","type":"post","link":"https:\/\/www.boostsolutions.com\/blog\/how-to-hide-the-site-actions-drop-down-list-using-javascript\/","title":{"rendered":"How to hide the Site Actions drop down list using JavaScript"},"content":{"rendered":"<p style=\"text-align: left;\" align=\"center\"><span style=\"line-height: 1.5;\">When you normally open SharePoint 2010 you will find the Site Action drop down list on the top left:<\/span><\/p>\n<p style=\"text-align: left;\" align=\"center\"><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-5556 alignnone\" alt=\"How to hide the Site Actions drop down list using JavaScript\" src=\"http:\/\/www.boostsolutions.com\/blog\/wp-content\/uploads\/2013\/06\/image0011.png\" width=\"261\" height=\"281\" \/><\/p>\n<p>This post will demonstrate how to hide the Site Actions drop down list using JavaScript.<br \/>\nFirst, create an empty SharePoint solution using VS and then add a custom action:<\/p>\n<pre>&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\r\n&lt;Elements xmlns=\"http:\/\/schemas.microsoft.com\/sharepoint\/\"&gt;\r\n&lt;CustomAction\r\nId=\"HideSiteActions.SiteActionAddPoint\"\r\nGroupId=\"SiteActions\"\r\nLocation=\"Microsoft.SharePoint.StandardMenu\"\r\nSequence=\"1003\"\r\nControlAssembly=\"$SharePoint.Project.AssemblyFullName$\"\r\nControlClass=\"HideSiteActions.SiteActionAddPoint\"\/&gt;\r\n&lt;\/Elements&gt;<\/pre>\n<p>The ControlClass is defined as follows:<\/p>\n<pre>namespace HideSiteActions\r\n{\r\npublic class SiteActionAddPoint : Control\r\n{\r\nprotected override void OnPreRender(EventArgs e)\r\n{\r\nbase.OnPreRender(e);\r\nbool HideSiteActions = true;\r\n\/\/check permissions to set HideSiteActions to false or true.\r\n\/\/HideSiteActions = \/\/SPContext.Current.Web.DoesUserHavePermissions(SPBasePermissions.FullMask);\r\nif (HideSiteActions)\r\n{\r\nstring JSKey = \"JSHideSiteActions\";\r\nType JSType = this.GetType();\r\nstring JScript = string.Format(\"document.getElementById('siteactiontd').style.display = 'none';\");\r\nif (!this.Page.ClientScript.IsStartupScriptRegistered(JSType, JSKey))\r\n{\r\nthis.Page.ClientScript.RegisterStartupScript(JSType, JSKey, JScript, true);\r\n}\r\n}\r\n}\r\n}\r\n}<\/pre>\n<p>Use the &#8220;OnPreRender&#8221; function to render this java script code: (&#8220;document.getElementById(&#8216;siteactiontd&#8217;).style.display = &#8216;none&#8217;;&#8221;), to hide the Site Actions drop down list.<br \/>\nThe variable &#8220;HideSiteActions&#8221; is used to control Site Actions drop down list&#8217;s hide\/show based on permissions.<\/p>\n<p><span style=\"line-height: 1.5;\">After deploying this feature to SharePoint, refresh your page and the Site Action drop down list will be hidden.<\/span><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-5555\" alt=\"How to hide the Site Actions drop down list using JavaScript\" src=\"http:\/\/www.boostsolutions.com\/blog\/wp-content\/uploads\/2013\/06\/image002.jpg\" width=\"168\" height=\"212\" \/><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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: &lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;utf-8&#8243;?&gt; &lt;Elements xmlns=&#8221;http:\/\/schemas.microsoft.com\/sharepoint\/&#8221;&gt; &lt;CustomAction Id=&#8221;HideSiteActions.SiteActionAddPoint&#8221; [&hellip;]<\/p>\n","protected":false},"author":22,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1,125],"tags":[],"_links":{"self":[{"href":"https:\/\/www.boostsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/5554"}],"collection":[{"href":"https:\/\/www.boostsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.boostsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.boostsolutions.com\/blog\/wp-json\/wp\/v2\/users\/22"}],"replies":[{"embeddable":true,"href":"https:\/\/www.boostsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=5554"}],"version-history":[{"count":7,"href":"https:\/\/www.boostsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/5554\/revisions"}],"predecessor-version":[{"id":5562,"href":"https:\/\/www.boostsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/5554\/revisions\/5562"}],"wp:attachment":[{"href":"https:\/\/www.boostsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=5554"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.boostsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=5554"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.boostsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=5554"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}