Jump to content

Need a little help: What do I do wrong?


Hugo

Recommended Posts

Hey all,I'm trying to make a link which has the 'slide-navigation' - javascript snippet, but there should also change an image when moving the mouse over the link. Some background info:The images I want to use in the rollover are 'arrow.gif' and 'arrow1hover.gif', both 10 times 10 pixels in size.This is the code I have right now, starting with the HTML part:

<td><img src="arrow.gif" width="10" height="10" name="pic2" /><b>  </b><a href="index.htm" id="h2" class="leftlink" target="_top" onMouseover="shiftMe('h2','l',7);lightup('pic2')" onMouseout="shiftMe('h2','r',7);turnoff('pic2')">Home</a></td>

And here's the Javascript part:

<!--  if (document.images)   {	 pic2on= new Image(10,10);	 pic2on.src="arrow1hover.gif";	 	 pic2off= new Image(10,10);	 pic2off.src="arrow.gif";	    }function lightup(imgName) {   if (document.images)	{	  imgOn=eval(imgName + "on.src");	  document[imgName].src= imgOn;	} }function turnoff(imgName) {   if (document.images)	{	  imgOff=eval(imgName + "off.src");	  document[imgName].src= imgOff;	} }//-->function shiftMe(object, direction, pixels){	if (pixels==0)return;	var obj = document.getElementById(object);	if (obj.style.marginLeft=="") obj.style.marginLeft="0px";	var marginLeftVal=obj.style.marginLeft;	var marginLeftInt=new Array();	marginLeftInt=marginLeftVal.split('p');	if (direction=="r")	marginLeftInt[0]--;	if (direction=="l")	marginLeftInt[0]++;	pixels--;	obj.style.marginLeft=marginLeftInt[0]+"px";	timer=setTimeout('shiftMe("'+object+'","'+direction+'",'+pixels+')',1);}

Here is the shiftMe function copied from this forum's list of JS snippets. The link does do the navigation slide thingie when I call that function, so without the "turnoff('pic2')" and "lightup('pic2')" in the onmouseover/onmouseout events. However, when I add the rollover function it doesn't work , just the navigator slide thing. I hope someone can help me out. Thank you in advance,-Hugo.

Link to comment
Share on other sites

so.. nobody knows how to do a rollover on a link and the navigation-slide thingie at the same time?[bump]
Hi, just pasted your code and it works out-of-the-box for me (in FF and IE7).When I move the mouse over the link, it moves, and the images to its left change from one to the other.Sure your GIFs are in the current folder? Have different appearance from each other etc?What are you (not) seeing when you run it?
Link to comment
Share on other sites

Hi, just pasted your code and it works out-of-the-box for me (in FF and IE7).When I move the mouse over the link, it moves, and the images to its left change from one to the other.Sure your GIFs are in the current folder? Have different appearance from each other etc?What are you (not) seeing when you run it?
hey that's funny. I copied it back from my post into my html page, and it works indeed :) I am 99% sure I just copied and pasted it right from the html into my post when I posted it.anyway, thank you for testing, sorry for wasting your time..-Hugo
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...