Forum Moderators: open

Message Too Old, No Replies

Rollover questions

Mouse goes over a link and changes a different image.

         

riotfire

7:52 pm on Nov 12, 2003 (gmt 0)

10+ Year Member



Is there a way I can create a link that when the mouse rolls over it, it will change a different image on the page

DrDoc

8:03 pm on Nov 12, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sure! As long as the rollover script points to that image (using its name or ID).

YorkshireSteve

7:25 pm on Nov 13, 2003 (gmt 0)

10+ Year Member



Inside the <a> tag:

onMouseOver="document.imageToChange.src='newImage.jpg'"

Tip: Pre-load the image in the <body> tag using the onLoad handler. -- That way, the image changes immediately, rather than downloading it first.

Changing the source of an image is also an excellent way to preview an image in a file input field of a form -- Change the src to the location on the user's file on their local machine and use the onChange handler to set it.

Steve.

riotfire

7:51 pm on Nov 13, 2003 (gmt 0)

10+ Year Member



Thanks A Bunch!