Thursday, August 20, 2009

Hiding Menu in DispForm.aspx (MOSS 2007)

Sometimes, you may struggle to hide the "Menu Toolbar" which is displaying in the top of the Display Form page.



You may tried to hide by editing the page in SP Designer & writing Java Scripts. But they will not reflect in page. Because, you may forgot to add the "Push" method.

OK. So, here is an sample script, that will hide the "Menu Toolbar" from the DispForm.aspx.

<script language="javascript" type="text/javascript">
function check()
{
var elements=document.body.getElementsByTagName("a");
for (var index=0; index <>
{
if(elements[index].title.toLowerCase()=="edit item")
elements[index].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.style.display="none";
}
}  
var elements=document.body.getElementsByTagName("td");
for (var index=0; index <>
{
if(elements[index].innerText.toLowerCase()=="itemworkspaceurl")
elements[index].parentNode.style.display="none";
}
}  
}
_spBodyOnLoadFunctionNames.push("check()");
</script>


Once you have applied this script, final screen will be like,




That's It...

4 comments:

  1. Hi,

    Its great post, but can we write something from the front end to achieve this?

    Anindya

    ReplyDelete
  2. Can we add this code inside Content Editor Web part and run as hidden?

    ReplyDelete
  3. Yes, you can do this in Content editor web part...

    ReplyDelete