Is it possible to have links on a page change color and disable when they are active, it's an added touch to a link. Normally you can just set active link color, but I was curious if you could make the link turn to text when active.
Printable View
Is it possible to have links on a page change color and disable when they are active, it's an added touch to a link. Normally you can just set active link color, but I was curious if you could make the link turn to text when active.
I'm going to assume that you're talking about some sort of navigation system. You can do anything you want with switches in the URL. It could get very complex, but basically you'd have to set a series of flags and include it in the URL.
There is no way using CSS to do this like a:active = nolink or something as simple as that.
Colors are also possible, but would have to follow the same routine as setting the links to text.
I'm not really sure what you mean.Quote:
Originally posted by J_Man
Is it possible to have links on a page change color and disable when they are active, it's an added touch to a link. Normally you can just set active link color, but I was curious if you could make the link turn to text when active.
Do you mean a navigation system, whereby when the user clicks the link in the navigation bar, the page loads and the link turns to standard text?
If so this is relitively simple with PHP. Have a look at the example below:
PHP Code:<?php
header ('Content-Type: text/html; charset=iso-8859-1');
$location = (isset ($_GET['location'])?$_GET['location']:'home');
/* array of items you want to include in your navigation bar
* the key corresponds to the query string values and the value
* corrsesponds to the link text
*/
$navbar = Array ('home' => 'Home',
'link1' => 'Link 1',
'link2' => 'Link 2',
'link3' => 'Link 3',
'link4' => 'Link 4');
?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Links</title>
</head>
<body>
<div class="main">
<div>
<h2>Navigation Bar</h2>
<table class="navbar">
<tr>
<?php foreach ($navbar as $key => $value): ?>
<td>
<?php if ($location != $key): ?>
<a href="<?php link_self("location=$key")?>"><?php echo ($value) ?></a>
<?php else: echo ($value) ?>
</td>
<?php endif; endforeach; ?>
</tr>
</table>
</div>
</body>
</html>
<?php
function link_self ($querystring = '') {
echo (htmlspecialchars ($_SERVER['SCRIPT_NAME'] . ($querystring == ''?'':"?$querystring")));
}
?>
how do I make it display like a list? it comes out horizontal, I can't change it
Put a <br> or 2 after each one?
Change the middle bit of the code to this. It uses table rows.
PHP Code:<?php foreach ($navbar as $key => $value): ?>
<tr>
<td>
<?php if ($location != $key): ?>
<a href="<?php link_self("location=$key")?>"><?php echo ($value) ?></a>
<?php else: echo ($value); endif; ?>
</td>
</tr>
<?php endforeach; ?>
it's not designed like thatQuote:
Originally posted by ober0330
Put a <br> or 2 after each one?
Sorry... it's Monday morning. I wasn't thinking straight.