I'm trying to hide a particular div (id=contactinfo) on the page when the current URL ends in /folder1/. For example:
http://example.com/folder1/
https://example1.net/FOLDER1/
example2.org/Folder1/
example3.com/folder1/
subdomain.example.com/folder1/
intranet/folder1/
Here's what I have, which doesn't hide the div:
<script type="text/javascript">
if (window.location.href.toLowerCase() == "[^ ]*/folder1/".toLowerCase()) {
document.getElementById("contactinfo").style.display = "none";
}
else {
document.getElementById("contactinfo").style.display = "block";
}
</script>
I'm new to JavaScript and suspect there might be a problem with using regex in a literal comparison. Any suggestions would be greatly appreciated.