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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mouse images URGENT

Status
Not open for further replies.

Gregsy35

Programmer
Dec 5, 2000
21
CA
i no there is a way to change an image on a mouse over by alterin teh src of the image in a written function my is:

function selectColor(imageNam)
{
document.images[imageNam].src=('../images/'+ imageNam + '1.gif');
}
when i do this it says there is no such object as document.images[..] how do i ref n change an image within a web page, it is drivin me crazy, thanks guys
 
Hi Gregsy35!

You should also add an html part, maybe there's an error.
Anyway, here is a code that you need:

<script language=&quot;Javascript&quot;>
<!--
if (document.images)
{
img1=new Image();
img1.src=&quot; ... &quot;;
img2=new Image();
img2.src=&quot; ... &quot;;
}

function change(imgNumb,imgFile)
{ if (document.images)
{ document.images
.src = eval(imgFile + '.src'); }
}
//-->
</script>

and the html part is:

<a href=&quot;&quot; onMouseOver=change('n1','img2') onMouseOut=change('n1','img1')>
<img src=&quot;someimage.gif&quot; name=n1 border=0></a>

Checked hundreds of times. Just remember to change NAME attribute of each image involved.

Andrew | starway@mail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top