I'm new to javascript but am trying to conditionally display a button/link on a page if it matches a certain url with the code below:
LinkNode = document.getElementById("csv");
var url = document.documentURI
if(document.documentURI.substr(url.lastIndexOf("/"+1)) == "/colleagues"){
LinkNode.style.visibility= "visible";
}
else{
LinkNode.style.visibility= "hidden";
}
Can anyone advise what I am doing wrong or how to match my url ending in "/colleagues" because this isn't matching? Is it possibly easier to use a regex?
How might I test to see what document.documentURI.substr(url.lastIndexOf("/"+1)) is actually producing?