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

Rollover won't work

Status
Not open for further replies.

spinningman

Programmer
Oct 17, 2003
9
GB
For some reason I can't fathom out, my second rollover image isn't recognised on my site. I just get the red X. I've FTP'd it and its there on the server but it is not being recognised. ?????

The site:
The script I am using:

<script language="JavaScript">
image1 = new Image();
image1.src = "images/opening1.gif";
image2 = new Image();
image2.src = "images/opening2.gif";

function movepic(img_name,img_src)
{ document
.src=img_src; }
</script>

'the body......'
<div align="center">
<a href="../index.html" onmouseover="movepic('button','Images/opening2.gif')"
onmouseout="movepic('button','Images/opening1.gif')">
<img name="button" src="Images/opening1.gif" width=77 height=33 border=0 alt="Home button"></a>
</div>
 
Instead of passing the path on the second parameter pass the image source ie image1 or image2.

onmouseover="movepic('button','image2')"

onmouseout="movepic('button','image1')"



--------------------------------
Codito, ergo sum
 
You're almost there.

Preloading:
Code:
image1 = new Image();
image1.src = "images/opening1.gif";
image2 = new Image();
image2.src = "images/opening2.gif";

Function:
Code:
function movepic( newImg, targImg ) {
  if (document.images)
    document[targImg].src = newImg.src;
}

Call To Function:
Code:
<a href="../index.html" onmouseover="movepic(image2, 'button'); return false;" onmouseout="movepic(image1,'button'); return false;">

*cLFlaVA
----------------------------
[tt]tastes great, less filling.[/tt]
 
Everyone's got their way. Here's mine:

function over(imgname,imgsrc) {
document
.src=imgsrc;
}
function out(imgname,imgsrc) {
document
.src=imgsrc;
}

And then your HTML looks like:

<A HREF="page.html"
onmouseover="over('button','opening2.gif')"
onmouseout="out('button','opening2.gif')">
<IMG SRC="opening2.gif" NAME="button"> </A>

Dispensing quality rants and mishaps since 1999:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top