Lets say your site has three areas: blog – about – links. When you're on the blog page, you want the link "blog" to be bold (or a different color, or a different image, etc.) but you're using an include for the navigation, (and besides, customizing it for each page is a pain). Again, probably more ways to do this… here's one way in Javascript:
It's kind of clunky but you need an "identifier" on each page. A javascript variable that you can later check on it's value to find out what page you're on.
So for example, on the blog page, you'd have this:
<script language="Javascript">
var thisPage = "blog";
</script>
on the about page that "var thisPage line would look like:
var thisPage = "about";
etc. etc.
THEN, on your navigation include – you show the link/buttons depending on which page you're on:
<script language="Javascript">
//write blog link..
if (thisPage == "blog") {
// we're on the blog page, so let's write blog bold and without a link:
document.write("<b>blog</b>");
} else {
//we're not on the blog page, so let's write it normal:
document.write("<a href=\"/blog.php\">blog</a>");
document.write(" | "); //writing in a little "visual" seperator
//write about link
if (thisPage == "about") {
document.write("<\b>about</b>");
} else {
document.write("<a href=\"/about.php\">about</a>");
}
document.write(" | "); //"visual" seperator
//write links link
if (thisPage == "links") {
document.write("<b>links</b>");
} else {
document.write("<a href=\"/links.php\">links</a>");
}
</script>
additional notes: anywhere you place that script that checks that "thisPage" variable will need the definition of that varible ON THAT PAGE. Otherwise you'll get a javascript error.