Sharepoint 2013 通过Feature隐藏(Site Action)菜单

不善言语,直接贴代码(也可通过js或css去隐藏),以下是各个菜单选项

zz2_ID_PersonalInformation 我的设置
zz3_ID_LoginAsDifferentUser 以其它用户登录  (这个是自己加上去的,为了方便测试)
zz4_ID_Logout   注销         
zz5_ID_PersonalizePage  对本页面进行个性化设置
zz8_MenuItem_ShareThisSite 共享
zz9_MenuItem_Create  添加应用程序  
zz10_MenuItem_ViewAllSiteContents 网站内容
zz11_MenuItem_Settings 网站设置
ctl00_ctl46_SiteActionsMenuMain_ctl00_wsaCreatePage 添加页
ctl00_ctl46_SiteActionsMenuMain_ctl00_wsaDesignEditor 设计管理器
ctl00_ctl46_SiteActionsMenuMain_ctl00_wsaEditPage
ctl00_ctl46_SiteActionsMenuMain_ctl00_wsaShowMenu 显示功能区
ctl00_SiteActionsMenuMain_ctl00_ctl00 入门

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <CustomAction
   Location="ScriptLink"
  ScriptBlock="                       
            function loadjQueryScripts(src) {          
                      
                      var head = document.getElementsByTagName('head')[0];          
                      var script = document.createElement('script');          
                      script.type = 'text/javascript';           
                      script.src = src;           
                      head.appendChild(script);  
            }                   
           function hideSiteActions() {
            var menuItems = document.getElementsByTagName('ie:menuitem');
                for (var key in menuItems)
                {
                
                   if(key.endsWith('PersonalInformation'))
                      {
                          menuItems[key].parentNode.removeChild(menuItems[key]);
                      }                     
                }
                

          }
          _spBodyOnLoadFunctionNames.push('hideSiteActions');
"
   Sequence="10001">
  </CustomAction>
</Elements>

比如我们需要隐藏网站内容: key.endsWith('ViewAllSiteContents') 即可。

 

posted @ 2014-01-17 11:02  gaoxingstyle  阅读(610)  评论(0编辑  收藏  举报