0

I have this rollover image for my final project in class and I need to use Dreamweaver's features to help accomplish this task.

So after doing it, my rollover image doesn't work.

Here is what it looks like without mouseover:

https://i.stack.imgur.com/CdEOL.jpg

and here is what it looks like with mouseover (or suppose to anyways):

https://i.stack.imgur.com/6gZvF.jpg

I feel dreamweaver probably put some unnecessary coding in there which is why it is not quite working, so the coding that it did for me is:

<p>
<a href="index.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('1st-Link','','images/1st-link-roll.jpg',1)"><img id="firstlink" src="images/1st-link.jpg" alt="TAP" id="1st-Link" /></a><a href="whatis.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('2nd-Link','','images/2nd-link-roll.jpg',1)"><img id="rollover" src="images/2nd-link.jpg" alt="Who is TAP" id="2nd-Link" /></a><a href="why.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('3rd-Link','','images/3rd-link-roll.jpg',1)"><img id="rollover" src="images/3rd-link.jpg" alt="Why we do it" id="3rd-Link" /></a><a href="resources.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('4th-Link','','images/4th-link-roll.jpg',1)"><img id="rollover" src="images/4th-link.jpg" alt="Resources" id="4th-Link" /></a>
</p>

and the JavaScript it put in is:

<script type="text/javascript">
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
</script>

I don't know if you need it or not, but my CSS is:

#rollover
{
    display:block;
    width:120px;
    border:1px solid #000;
    float:left;
    margin-top:30px;
    border:1px solid #000
}

#firstlink
{
    display:block;
    width:120px;
    border:1px solid #000;
    float:left;
    margin-top:30px;
    margin-left:265px;
}
tomsullivan1989
  • 2,760
  • 14
  • 21
  • 5
    With all respect a sponge knows more about web than your Teacher... all junk code of Dreamweaver to do that is useless. – DaniP Jan 15 '14 at 15:58
  • 2
    `I feel dreamweaver probably put some unnecessary coding in there` - You got that right! There is no need to use `Javascript` for image rollovers. Please see my answer from yesterday, which was about a similar issue - http://stackoverflow.com/questions/21117218/creating-css-sprite-hover-roll-over-image-links/21117400#21117400 This can be accomplished with just `CSS` – Nick R Jan 15 '14 at 16:03

1 Answers1

1

You don't need to use images or JavaScript at all. You could simply use divs and a hover effect to change the colour like so:

HTML:

<div class="rollover">TAP</div>

CSS:

.rollover
{
    display:block;
    width:120px;
    text-align:center;
    background-color:yellow;    
}

.rollover:hover
{
    background-color:red;    
}

If you do need to use an image, then you can do a similar thing with a hover effect that alters the background image of the div.

See this DEMO.

tomsullivan1989
  • 2,760
  • 14
  • 21
  • I was just about to suggest using HTML/CSS . You beat me to it. – Jez D Jan 15 '14 at 16:08
  • I actually made it where I just changed my color, but then he yelled at me because it is suppose to be a rollover image. Although infuriated, since my entire grade depends on it and he checks the coding, I have to use a rollover image. It has to be java whether or not I want it to be – Mathew Crogan Jan 16 '14 at 16:22
  • Your tutor is an arse then. I can't see any reason why you would use JavaScript for a simple rollover like this. Obviously he is wanting to test your JavaScript skills but he could at least think of a task that would require using JS. – tomsullivan1989 Jan 16 '14 at 16:52
  • Oh yea, it is pretty bad. I know some javascript but he never taught us any the entire year. They literally just told us what buttons to press in dreamweaver – Mathew Crogan Jan 21 '14 at 13:02