Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

HTML Forum


You are currently viewing our HTML Forum as a guest. Please register to participate.
Login



Post a Project »

Find a Professional HTML Freelancer!

Find a Freelancer to help you with your HTML projects

FREE Outsourcing eBook!

Reply
Can a LINK know its already at its destination and not work ....
Old 10-28-2005, 01:26 PM Can a LINK know its already at its destination and not work ....
Experienced Talker

Posts: 31
Trades: 0
Can a LINK know its already at its destination and not work. If I am at a page called MyPage.html, and on that page there is a link to it:
HTML Code:
<a href="../MyPage.html"><img src="../images/MyPage.gif"></a>
is there a way of it being automatically disabled.

The reason for this is because I have some standard navigation that is used on many pages, and i want to avoid changing code for every page its on.

It is fair to say that i am not using a roll-over image, or link text, so i am only trying to do this to stop;
1. pointless page reloading,
2. the impression of a link to somehwere there's not,

Any help appreciated, Simon.
simonwar is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-28-2005, 01:53 PM
someguy's Avatar
Extreme Talker

Posts: 151
Location: UK
Trades: 0
Not hard to do within a scripting language such as PHP. Simply check the current URL against the URL on the link and change the output if they match.
someguy is offline
Reply With Quote
View Public Profile
 
Old 10-28-2005, 01:57 PM
Miki's Avatar
Skilled Talker

Posts: 72
Name: Michael Stubbs
Location: Warrington, UK
Trades: 0
Any code examples please as I would also be very interested in this.
Miki is offline
Reply With Quote
View Public Profile
 
Old 10-29-2005, 06:11 AM
someguy's Avatar
Extreme Talker

Posts: 151
Location: UK
Trades: 0
This should do the trick. I've packaged it in a little function to make life easier. The good thing with this is that you can just chuck the whole menu in an include or something if you like.

Only thing to remember is to use absolute paths (/index.php) rather than relative ones (index.php).

OK, code comes in two parts:

Put this bit up the top of the page, or include it up there:
Code:
<?php
// put the test in a function so that you don't have to keep repeating it
function showLink($thisPage,$destination,$linkText){
	if ($thisPage == $destination){
		$output = $linkText;
	} else {
		$output = '<a href="'.$destination.'">'.$linkText.'</a>';
	}
	return $output;
}

// Now find out what page is being viewed.
$thisPage = $_SERVER['REQUEST_URI'];
?>
Then just do something like the following where you want the menu to appear:

Code:
* <?php echo showLink($thisPage,"/test/test.php","Test Page One"); ?><br>
* <?php echo showLink($thisPage,"/test/test2.php","Test Page two"); ?><br>
* <?php echo showLink($thisPage,"/test/test3.php","Test Page three"); ?><br>
Hope that this helps. Let me know.
someguy is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Can a LINK know its already at its destination and not work ....
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.36018 seconds with 12 queries