driven_13
asked on
"Unlink" an active link when on a particular page
Hello experts.
I have had some awesone help in figuring out how to change the color of an active link when you are on the page the link is pointing to.
Check it out here: https://www.experts-exchange.com/questions/28026727/Using-CSS-to-color-an-active-menu-link-differently.html
Now I need some help figuring out how to make that link in the menu inactive (not clickable) when you are on the page that link is pointing to.
I have included what I have so far, below.
Thanx in advance,
--d.
I have had some awesone help in figuring out how to change the color of an active link when you are on the page the link is pointing to.
Check it out here: https://www.experts-exchange.com/questions/28026727/Using-CSS-to-color-an-active-menu-link-differently.html
Now I need some help figuring out how to make that link in the menu inactive (not clickable) when you are on the page that link is pointing to.
I have included what I have so far, below.
Thanx in advance,
--d.
#floatMenu {
position: fixed;
/* top:50%; */
top:350px;
margin-left:700px;
margin-top: -2em;
width:200px;
}
#floatMenu ul {
margin-bottom:20px;
}
#floatMenu ul li a {
display:block;
border:1px solid #999;
background-color:#222;
border-left:6px solid #999;
text-decoration:none;
color:#ccc;
padding:5px 5px 5px 25px;
}
#floatMenu ul.menu1 li a:hover {
border-color:#09f;
}
#floatMenu ul.menu1 li a.red {
border:1px solid #BC181F;
border-left:6px solid #BC181F;
}
<script type="text/javascript">
window.onload = function() {
var anchors = document.getElementById("floatMenu").getElementsByTagName("a");
for(var i=0;i<anchors.length;i++) anchors[i].className = (location.href.indexOf( anchors[i].href.split("/").pop() ) > 0)?"red":"";
}
</script>
<div id="floatMenu">
<ul class="menu1">
<li><a href="link1.php"> Link 1 </a></li>
<li><a href="link2.php"> Link 2 </a></li>
<li><a href="link3.php"> Link 3 </a></li>
</ul>
</div>
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Worked out nicely.
Regards,
--d.