Jump to content

current link color


takeiteasy

Recommended Posts

hi there,
i need someone to help me out here, currently, my navigation menu is made up of a few links.
I wanted to display a different color for the link which the user is currently viewing, so as to differentiate or to let the user know which part he is in currently.
Is there any such of codes?Can give me a sample code?

my current code:
[code]
a:link {text-decoration: none; color: #ffffff; cursor:crosshair}
a:visited {text-decoration: none; color: #0000CC; cursor:crosshair}
a:active {text-decoration: underline; color: #444444; cursor:crosshair}
a:hover {text-decoration: underline; color: #6699FF; cursor:crosshair}
[/code]
Link to comment
Share on other sites

Provided that the menu is on every page (though highly un-recommended), you do have the option to simply get rid of the link and replace it with text.

Other wise you could use php (of course there are always other options).

In php, one way to do this, though it may not be the best way to do this, you could assign each page its own variable and use php to decide which variable is on that page. You now know what page the user is on and can take the appropriate action.

For example:

Page: elephants.php:
[code]
<html>
<head><title></title></head>
<body>

<?php $page = “elephants“; ?>
<!-- here is your menu --
<?php
if (page = “home“){echo “<font color=“#ff0000”><u>Home</u></font>“;}
else {echo “<a href=“home.php”>Home</a></br>“;}

if (page = “elephants“){echo “<font color=“#ff0000”><u>Elephants</u></font>“;}
else {echo “<a href=“elephants.php”>Elephants</a></br>“;}
?>

</body>
</html>
[/code]

That would display like this:

[url=http://Home]Home[/url]
[color=red][u]Elephants[/u][/color]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.