Click to See Complete Forum and Search --> : link color stay when clicked on -- same page
earth2mac
01-19-2010, 02:59 PM
Hopefully it's possible with css, but not sure.. I have some links on a side menu bar that each swap out content in a side window. I want each one to change a color ie to blue once clicked on with new content on side changed. The content swap is all done through jquery, but how can i have link color for each one updated?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript">
window.onload=function() {
document.getElementById('menu').onclick = active;
};
function active(e) {
if ( typeof active.aLinks == 'undefined' ) { // save the list
var aObj = document.getElementById('menu').getElementsByTagName('a');
var i = aObj.length;
active.aLinks = [];
while(i--) {
active.aLinks.push(aObj[i]);
}
}
var e = e? e : window.event;
var target = e.srcElement || e.target;
if(target.nodeName.toUpperCase()=='A') {
var i = active.aLinks.length;
var aLinks = [];
while(i--) {
active.aLinks[i].style.background = '#ccc'; // reset background
}
target.style.background = '#9cf'; // active link
}
return false;
}
</script>
<style type="text/css">
#menu {width:7em;}
#menu a {display:block; background:#ccc; padding:2px 5px;}
</style>
</head>
<body>
<ul id="menu">
<li><a href="home.htm">home</a></li>
<li><a href="pruducts.htm">pruducts</a></li>
<li><a href="contact.htm">contact</a></li>
</ul>
</body>
</html>
spacemoc
07-18-2011, 06:06 AM
why those links doesn't work when you click them? The highlight works but the link doesn't, you need to open it in the separate window to be able to access this link, I mean "Open link in new tab" ?
spacemoc
07-19-2011, 03:42 AM
Could someone tell me why I can not click that links but need to open in new tab? Is there is any way of changing that? So I can use normal left mouse click