Hi linux1880,
i assume you need the following:
make a file called highlight.js with the following code:
Code:
function extractPageName(hrefString)
{
var arr = hrefString.split('/');
return (arr.length<2) ? hrefString : arr[arr.length-2].toLowerCase() + arr[arr.length-1].toLowerCase();
}
function setActiveMenu(arr, crtPage)
{
for (var i=0; i<arr.length; i++)
{
if(extractPageName(arr[i].href) == crtPage)
{
if (arr[i].parentNode.tagName != "DIV")
{
arr[i].className = "current";
arr[i].parentNode.className = "current";
}
}
}
}
function setPage()
{
hrefString = document.location.href ? document.location.href : document.location;
if (document.getElementById("main_menu")!=null)
setActiveMenu(document.getElementById("main_menu").getElementsByTagName("a"), extractPageName(hrefString));
}
Put this in the head of your html page:
Code:
<script type="text/javascript" src="/js/highlight.js"></script>
And this is the code for the menu itself:
HTML Code:
<div id="main_menu">
<ul>
<li><a href="page1.html">page1</a></li>
<li><a href="page2.html">page2</a></li>
<li><a href="page3.html">page3</a></li>
<li style="background:none" class="last"><a href="page.4html">page4</a></li>
</ul>
<script type="text/javascript">setPage()</script>
</div>
The css styles:
Code:
#main_menu { height: 29px; width: 94%; margin-left: 6%; text-transform:uppercase; padding-top: 6px; font-size: 13px; float: left; margin-top: 200px; }
#main_menu li {float:left; list-style-type:none; background:url(/images/menu-line.gif) no-repeat right 5px;}
#main_menu li a { text-decoration:none; color:#3c4044; padding: 0px 19px 0 19px; display:block; margin-top:3px; padding-bottom: 5px; font-weight: bold; }
#main_menu li a:hover {color: #FFF; text-decoration:none;}
#main_menu li .last { background:none;}
#main_menu li .last a { padding-right:0;}
#main_menu li .current {color:#FFF; text-decoration:none;}
The class .last is for the menu divider (as an image) and in the class .current you can set the highlight color and text-decoration.
Hope this helps you....
Grtz
Bookmarks