|
-
Aug 16th, 2004, 02:00 AM
#1
Thread Starter
Junior Member
when link is active, disable it
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.
-
Aug 16th, 2004, 06:57 AM
#2
Frenzied Member
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.
-
Aug 16th, 2004, 07:51 AM
#3
Re: when link is active, disable it
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.
I'm not really sure what you mean.
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")));
}
?>
-
Aug 16th, 2004, 09:36 AM
#4
Thread Starter
Junior Member
how do I make it display like a list? it comes out horizontal, I can't change it
-
Aug 16th, 2004, 09:44 AM
#5
Frenzied Member
Put a <br> or 2 after each one?
-
Aug 16th, 2004, 09:55 AM
#6
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; ?>
-
Aug 16th, 2004, 10:07 AM
#7
Thread Starter
Junior Member
Originally posted by ober0330
Put a <br> or 2 after each one?
it's not designed like that
-
Aug 16th, 2004, 11:03 AM
#8
Frenzied Member
Sorry... it's Monday morning. I wasn't thinking straight.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|