Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder saeed's Avatar
    Join Date
    Oct 2002
    Location
    West Yorkshire
    Posts
    343
    Thanks
    32
    Thanked 0 Times in 0 Posts

    Current Page Hyperlink disable

    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

    Code:
    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
    Code:
    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. Any help will be appreciated.

    Thank you,

    Saeed.
    Don't click on this!

    #!/usr/bin/saeed

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,531
    Thanks
    8
    Thanked 1,091 Times in 1,082 Posts
    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");?>

    PHP Code:
    <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($uristrrpos($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
    Last edited by mlseim; 01-09-2008 at 06:32 PM.

  • #3
    Regular Coder saeed's Avatar
    Join Date
    Oct 2002
    Location
    West Yorkshire
    Posts
    343
    Thanks
    32
    Thanked 0 Times in 0 Posts
    thank you very much

    appreciated!
    Don't click on this!

    #!/usr/bin/saeed

  • #4
    Senior Coder
    Join Date
    Feb 2003
    Posts
    1,665
    Thanks
    0
    Thanked 27 Times in 25 Posts
    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™

  • #5
    Regular Coder Actinia's Avatar
    Join Date
    Feb 2007
    Location
    Essex, UK
    Posts
    250
    Thanks
    1
    Thanked 23 Times in 22 Posts
    I have used delinking on my Pound Wood 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:
    Code:
    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
    Last edited by Actinia; 01-10-2008 at 10:49 AM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •