I am using the script below in a CEWP in MOSS to
hide empty list/library web parts, but it doesn't work when added as html to a
CEWP in SharePoint 2010. I've tried several other methods without success in
2010. Does anybody have any ideas for hiding empty web parts in 2010? Thanks.
Script used in 2007 (Test List=WP Name):
<script>
function HideWebPartWithZeroRows()
{
var a = document.getElementsByTagName("TABLE")
for (var i=0;i<a.length;i++)
{
if (a[i].summary=="Test List")
{
if (a[i].rows.length==1)
{
[i].parentNode.parentNode.parentNode.parentNode.parentNode
var x =
a[i].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNod\
e.parentNode.parentNode
x.style.display="none";
}
}
}
}
_spBodyOnLoadFunctionNames.push("HideWebPartWithZeroRows")
</script>