Tuesday, December 2, 2008

Deactivating the Multiple Documents Option for Upload

We had a business requirement to block the "Upload Multiple Documents" Option for the document library. So add "Content Editor Web Part" check the "Hide" under layouts section.
Then add below code under Source Editor and you are done!.

<script type="text/javascript">
function GetElementByText(tagName, title)
{
var a = document.getElementsByTagName(tagName);

for (var i=0; i < a.length; i++)
{
if (a[i].text)
{
if (a[i].text === title)
{
return a[i];
}
}
}
return null;
}

if (window.onload)
{
var oLoad = window.onload;
window.onload = function bodyLoad()
{
oLoad();
var oMenu = GetElementByText("ie:menuitem","Upload Multiple Documents");
if (oMenu )
{
oMenu .disabled = true;
}
}
}

</script>

Note: If you want to deactivate the Upload Document change the var oMenu ;
var oMenu = GetElementByText("ie:menuitem","Upload Documents");

No comments: