Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remove Link 2

Status
Not open for further replies.

bdichiara

Programmer
Joined
Oct 11, 2006
Messages
206
Location
US
I'm trying to accomplish a thumbnail view using javascript. So far it all works pretty good, except when I go from an image that is larger than my set dimensions to an images that is smaller, I want to be able to remove the "link". Right now, I'm just setting the href to '', however in IE7 (possibly IE6), if I click on it, it takes me to the Url: '' which is not like # (in firefox) but more like " I want the link to be removed altogether. See the link is simply viewing the file in a new window. I don't want it to do that if the image is already as large as it can be. So, what i'm asking is, in my function, is it possible to just to make the link not work?

This is the function that changes the larger image source (which is 250px in height). And I have PHP code that sets TRUE or FALSE if it is larger than 250px.
Code:
function setSource(filename,caption,larger){
  document.getElementById("mainimg").src = "phpThumb/phpThumb.php?src=../"+filename+"&h=250";
  if(larger == "true"){
    document.getElementById("fullimg").href = filename;
    document.getElementById("fullimg").target = "fullsize";
    document.getElementById("mainimg").style.cursor = "pointer";
    document.getElementById("mainimg").title = caption+" [click for larger view]";
    document.getElementById("mainimg").alt = caption+" [click for larger view]";
    document.getElementById("imgcaption").innerHTML = caption+" <span style=\"font-size:10px;\">[<a href=\""+filename+"\" target=\"fullsize\">click for larger view</a>]</span>";
  } else {
    document.getElementById("fullimg").href = '';
    document.getElementById("fullimg").target = "_parent";
    document.getElementById("mainimg").style.cursor = "default";
    document.getElementById("mainimg").title = caption;
    document.getElementById("mainimg").alt = caption;
    document.getElementById("imgcaption").innerHTML = caption;
  }
  return false;
}

_______________
_brian.
 
one way is to try doing something like this:

Code:
document.getElementById("fullimg").href = '#';
document.getElementById("fullimg").onclick = function() { return false; };



*cLFlaVA
----------------------------
[tt]"quote goes here"[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
try changing this:
Code:
    document.getElementById("fullimg").href = '';
to this:
Code:
    document.getElementById("fullimg").href = '[!]#[/!]';
    [!]document.getElementById("fullimg").onclick = function () {return false};[/!]

-kaht

[small](All puppies have now found loving homes, thanks for all who showed interest)[/small]
 
I swear I didn't copy/paste that, had to make sure I didn't need a new in front of the function delcaration on the onclick [lol]

-kaht

[small](All puppies have now found loving homes, thanks for all who showed interest)[/small]
 
rofl. you guys crack me up. well, i tried both, and they both worked great! thanks for the help!

_______________
_brian.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top