Reputation: 113
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:
and here is what it looks like with mouseover (or suppose to anyways):
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;
}
Upvotes: 0
Views: 2234
Reputation: 2780
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.
Upvotes: 1