[thelist] NavBar, highlighting current link

abbey abbey at abbeyink.com
Fri Feb 21 11:43:01 CST 2003


A friend wrote this for me in php (I know you want to use javascript, but I
have this)

<?php
function link_compare($link, $text, $path='') {
        if ('/'.$path.$link == $_SERVER['PHP_SELF'])
                echo "\n  <span class=\"active\">&gt; $text</span><br><br>";
        elseif ($path != '')
                echo "\n  <a class=\"nav\"
\href=\"$path$link\">$text</a><br><br>";
        else
                echo "\n  <a class=\"nav\"
href=\"../$link\">$text</a><br><br>";
										}

/* USE
 * link_compare(LINK, TEXT[, PATH])
 *  LINK == file you are linking to
 *  TEXT == description text of link
 *  PATH (otional) == directory that LINK is in if not base directory (ends
with '/')
 */
function left_nav() {
 link_compare('gallery.html','Photo Gallery');
 link_compare('action.html', 'Action Packages');
 link_compare('services.html', 'Photo Services');
 link_compare('index.php','Sale Dates', 'Calendar/');
 link_compare('contact.html', 'Contact Us');
 link_compare('index.html', 'UA Home');

}

HTH



More information about the thelist mailing list