"Lois" <thiswillbounce (AT) excite (DOT) com> wrote
Quote:
Recently I created a site with a nav bar in table format across
the top of the page |
I don't think that you need a table here, it merely adds more code
while a DIV filled with A elements and a bit of CSS would do an
excellent job :-)
Quote:
If you were on "Other" page, for example, the background colour of the
"Other" cell was a different shade from the others. I created this by
altering the code on each page.
Now I'd like to have this different colour for the page name cell at another
site using SSI for the nav bar.
even more fun, some of the page names are entry points to another section of
the site. If I can make "Other" a different colour, for example, I'd also
like to make pages in the "Other" folder have this same feature so that
readers know that they're in the "Other" section of the site. |
A simple technique to achieve both goals would be to grab the
querystring and parse it; you can easily retrieve the folder part (the
section) to make the desired changes in your page, and the file name
part to update the corresponding menu item.
<div id="myMenu">
<a href="home.html">Home</a>
<a href="that.html">That</a>
<a href="this.html">This</a>
<a href="other.html">Other</a>
<a href="nav.html">Test</a>
</div>
<style type="text/css">
#myMenu a { background:green; color:white; padding:2px 15px}
#myMenu a:hover { background:yellow; color

range }
</style>
<script type="text/javascript">
(function(){
var d=document;
if(d.getElementById&&d.getElementsByTagName){
var pageParts=/\/([^\/]+)\/([^\/]+\.html?)$/.exec(location.href),
a=d.getElementById("myMenu").getElementsByTagName( "a");
//Update the link
for(var ii=0; ii<a.length; ii++){
if(a[ii].href.indexOf(pageParts[2])!=-1){
with (a[ii].style){ background="whitesmoke"; color="pink"; }
break;
}
}
//Update the section parts knowing that...
alert("You're in section : " + pageParts[1]) ;
}
})()
</script>
The function here just creates a specific scope, so that you can
safely put the js code in a js include, for instance in your SSI -
just update the id of the menu container, and maybe the extensions and
additional querystrings in the regexp.
HTH
Yep.