...

View Full Version : Current Page Hyperlink disable



saeed
01-09-2008, 06:02 AM
hello,

php and javascript is used in all pages of my websiite, I've got javascript includes for footer and 'links menu'. herez the code.

menu.js

document.write('<img src="img/menudivider.jpg" width="150" height="6" border="0" >');
document.write('<BR>');
document.write('&nbsp; <a href="index.php">Home</a><BR>');
document.write('<img src="img/menudivider.jpg" width="150" height="6" border="0" ><BR>');
document.write('&nbsp; <a href="intro.php">Introduction</a><BR>');
document.write('<img src="img/menudivider.jpg" width="150" height="6" border="0" ><BR>');
document.write('&nbsp; <a href="services.php">Programme Services</a><BR>');
document.write('<img src="img/menudivider.jpg" width="150" height="6" border="0" ><BR>');
document.write('&nbsp; <a href="components.php">Programme Components</a>');
document.write('<img src="img/menudivider.jpg" width="150" height="6" border="0" ><BR>');
document.write('&nbsp; <a href="join.php">Who can join PISD?</a>');
document.write('<img src="img/menudivider.jpg" width="150" height="6" border="0" ><BR>');
document.write('&nbsp; <a href="stakeholders.php">Stakeholders</a>');
document.write('<img src="img/menudivider.jpg" width="150" height="6" border="0" ><BR>');
document.write('&nbsp; <a href="publications.php">Publications</a>');
document.write('<img src="img/menudivider.jpg" width="150" height="6" border="0" ><BR>');
document.write('&nbsp; <a href="links.php">Useful Links</a>');
document.write('<img src="img/menudivider.jpg" width="150" height="6" border="0" ><BR>');
document.write('&nbsp; <a href="sitemap.php">Sitemap</a><BR>');
document.write('<img src="img/menudivider.jpg" width="150" height="6" border="0" ><BR>');
document.write('&nbsp; <a href="contactus.php">Queries / Feedback</a><BR>');
document.write('<img src="img/menudivider.jpg" width="150" height="6" border="0" ><BR>');

style.css

a {
font-family: Tahoma;
font-size: 11px;
text-decoration: none;
font-weight: bold;
color: #000000;
}

A:Hover {
color: #FF0000;
text-decoration: underline;
}

Problem:
I want current page link to be disabled and color changed (other than hyperlink color). I've seen on several websites but unfortunately this can't be done in CSS / Javascript (thats wht somebody told me) I was luckily able to change the font color using CSS on current page but can't disable the link.

Any idea how can I do this? I believe this can be done in PHP but dont know how. :confused: Any help will be appreciated.

Thank you,

Saeed.

mlseim
01-09-2008, 06:30 PM
The menu part will be done with PHP instead of Javascripting ...

It would be like this (this script could be called: "menu.php".
You include the script in your PHP pages where the menu will appear.
Like: <?php include("menu.php");?>



<img src="img/menudivider.jpg" width="150" height="6" border="0" >
<br />
<?php
//this gets the URL after the host name
$uri = $_SERVER['REQUEST_URI'];
$thisfile = substr($uri, strrpos($uri, '/') + 1);

// now we set up the display for each link
?>

<?php if ($thisfile == 'index.php') { ?>
&nbsp; <b>Home</b><br />
<?php }
else{?>
&nbsp; <a href="index.php">Home</a><br />
<?php } ?>
<img src="img/menudivider.jpg" width="150" height="6" border="0" ><br />

<?php if ($thisfile == 'intro.php') { ?>
&nbsp; <b>Introduction</b><br />
<?php }
else{?>
&nbsp; <a href="intro.php">Introduction</a><br />
<?php } ?>
<img src="img/menudivider.jpg" width="150" height="6" border="0" ><br />

<?php if ($thisfile == 'services.php') { ?>
&nbsp; <b>Programme Services</b><br />
<?php }
else{?>
&nbsp; <a href="services.php">Programme Services</a><br />
<?php } ?>
<img src="img/menudivider.jpg" width="150" height="6" border="0" ><br />

<?php if ($thisfile == 'components.php') { ?>
&nbsp; <b>Programme Components</b><br />
<?php }
else{?>
&nbsp; <a href="components.php">Programme Components</a><br />
<?php } ?>
<img src="img/menudivider.jpg" width="150" height="6" border="0" ><br />

.
.
.
etc

saeed
01-10-2008, 06:40 AM
thank you very much

appreciated! :thumbsup:

Bill Posters
01-10-2008, 09:12 AM
I've heard the arguments as to why some people choose to use them, but I'm not a great fan of delinking self-referential (sr), nav links. I consider the benefits of consistency to be more important than the supposed benefits that delinking sr links offers.
Imho, so long as the sr link is clearly differentiated (helping to denote the user's current location), there's little, if anything, to be gained by actually delinking it.
The argument in favour of delinking sr links is typically that clicking on a link which reloads the current page can confuse and disorient the user. However, I believe that delinked sr links are just a likely to cause confusion as an active, though differentiated, sr link amongst that bracket of users, possibly moreso, because they alter the functional consistency of the menu from page to page.

If you feel that you must delink sr links, have you considered simply 'faking' delinking them, by not only changing the colour, but also by changing the cursor to the default/text cursor? This would, at least visually, give the impression that the sr menu item is not a functioning link.

…though, as said, I'm far from convinced that it's a good idea to mess with menu consistency at all in that way.


…fwiw™ ;)

Actinia
01-10-2008, 10:47 AM
I have used delinking on my Pound Wood (http://www.poundwood.org.uk/Home/Home.htm) pages. This uses a combination of an id for each link, and a title attribute for the body tag on each page. An onload function looks at the title attribute and compares it with each navigation link id in turn. If these two are the same, then the href attribute of the link is deleted.

If javascript is disabled, then it is still clear that this is a sr link since the tooltip will make it clear this is where the user is.

If you want to follow the advice of Bill Posters, then use the following:

Give the page body a class corresponding to the id in the navigation link (say class="home"). Then in the common stylesheet, following the link styles, have:

body.home a#home { /* some neutral style */ }
This would need to be repeated for each link id in your navigation.

I can provide further details when I get my PC back from being upgraded.

John



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum