Category Archives: SharePoint 2007

SharePoint 2010 Bug – Hiding Empty Web Part Zones

I recently experienced a problem running SharePoint Server 2010 Oct 2013 CU and Internet Explorer 8. SharePoint has contained a function called MSO_MakeInvisibleIfEmpty() since the WSS 3.0 days, which hides a Web Part Zone if it is empty. The function works by looking for all elements in the DOM that have the name attribute set to “_invisibleIfEmpty”, and if there are no child nodes, it adds a style of display=”none”.

The function has the following definition:

function MSOLayout_MakeInvisibleIfEmpty()
{ULSKRf:;
	var allElements=document.getElementsByName("_invisibleIfEmpty");
	var agt=navigator.userAgent.toLowerCase();
	var isNav=((agt.indexOf('mozilla')!=-1)&&((agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible')==-1)));
	var isIE=(agt.indexOf("msie")!=-1);
	for (var curElement=0; curElement < allElements.length; curElement++)
	{
		if ((isIE && allElements[curElement].childNodes.length==0)
			|| (isNav && allElements[curElement].childNodes.length <=1))
		{
			allElements[curElement].style.display="none";
		}
	}
}

This function lives in the files IE50UP.js, IE55UP.js, and NON_IE.js, with SharePoint loading the appropriate file depending on your browser.

I am seeing the bug when running IE8 in native mode, in which case none of the 3 available JavaScript files are being loaded. If I turn on IE Compatibility Mode, or use Firefox or Chrome, the appropriate JavaScript files load.

As a work-around to this bug, I have pasted the contents of this function into a minified JavaScript file that I am using on my intranet’s home page.