If you have a lookup column in a List and in the AllItems.aspx if you want to disable the hyper link of that lookup values you can use this code
/*****************************************************************
_spBodyOnLoadFunctionNames.push("RemoveLookupLinks");
function RemoveLookupLinks()
{
var oP = document.getElementsByTagName('a');//the collection of a tags
var flag = falsefor(var i=0;i
if(oP[i].attributes["href"].value.indexOf("RootFolder=*")!= -1)
{
var linkvalue = oP[i].innerHTML;//value of the lookup field
oP[i].parentNode.innerHTML = linkvalue;//replacing value of the lookup to whole the Anchor tag
flag = true;
break;
}
}
if(flag)RemoveLookupLinks();
}
******************************************************************/
_spBodyOnLoadFunctionNames.push("RemoveLookupLinks");
function RemoveLookupLinks(){var oP = document.getElementsByTagName('a');//the collection of tags
var flag = false
for(var i=0;i
{
if(oP[i].attributes["href"].value.indexOf("RootFolder=*")!= -1)
{
var linkvalue = oP[i].innerHTML;//value of the lookup field
oP[i].parentNode.innerHTML = linkvalue;//replacing value of the lookup to whole the Anchor tagflag = true;
break;
}
}
if(flag)RemoveLookupLinks();
}
_spBodyOnLoadFunctionNames.push("RemoveLookupLinks");
function RemoveLookupLinks()
{
var oP = document.getElementsByTagName('a');//the collection of tags
var flag = falsefor(var i=0;i
{
if(oP[i].attributes["href"].value.indexOf("RootFolder=*")!= -1)
{
var linkvalue = oP[i].innerHTML;//value of the lookup field
oP[i].parentNode.innerHTML = linkvalue;//replacing value of the lookup to whole the Anchor tag
flag = true;
break;
}
}
if(flag)RemoveLookupLinks();
}
It looks for the anchor tags with href containg RootFolder=* and replaces that tag with its inner HTML. Because, Only lookup fields will have that kind of HREF.
No comments:
Post a Comment