Monday, October 10, 2011

Hide Breadcrumb Node in Breadcrumb Trail in SharePoint 2010

Hi, I came across a requirement that wanted to hide breadcrumb node in the breadcrumb trail.
I tried with navigation settings but it didn’t work out for me.Finally I landed up with JavaScript code.

My requirement was to hide “Department “from the following trail.

Home / Department / Labs / XYZ

So I used following JavaScript code for it.

script language="JavaScript"
var url = window.location.href;
if ((url.toString().indexOf("/Department /") > 0))
{
var breadNode = document.getElementById("ctl00_PlaceHolderTitleBreadcrumb_siteMapPath");
if ((breadNode != null) && (breadNode.childNodes[2] != null) && (breadNode.childNodes[3] != null))
{
breadNode.childNodes[2].style.display = 'none';
breadNode.childNodes[3].style.display = 'none';
}
}
/script


And following was the output:

Home / Labs / XYZ

For reference visit :
http://social.msdn.microsoft.com/Forums/en-US/sharepointcustomization/thread/0600ae0b-6925-483a-b5aa-6016f68c0d8b

Happy Coding :) :)

No comments:

Post a Comment