<a href="link" onMouseOver="document.image.src='on.gif'" onMouseOut="document.image.src='off.gif'">
<img src="off.gif" name="image">
</a>
It's pretty simple really, onMouseOver and onMouseOut are events that are triggered when the obvious happens: the mouse enters or leaves the image boundary. document is the current HTML file, image is the name of the image we're working with, and src is the value of the image. Assigning to document.image.src changes the image, and we only assign to it during an event. Notice in the second line that the name of the image is set and the original src is off.gif.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
<a href="link" onMouseOver="document.image.src='on.gif'" onMouseOut="document.image.src='off.gif'">
<img src="off.gif" name="image">
</a>
It's pretty simple really, onMouseOver and onMouseOut are events that are triggered when the obvious happens: the mouse enters or leaves the image boundary. document is the current HTML file, image is the name of the image we're working with, and src is the value of the image. Assigning to document.image.src changes the image, and we only assign to it during an event. Notice in the second line that the name of the image is set and the original src is off.gif.
Give this person a cigar and hope it stays unlit. Nice work and helpful too! Do you get these handy little code fields by just putting
some code here
around your text?
vegaseat
DaniWeb's Hypocrite
5,976 posts since Oct 2004
Reputation Points: 1,345
Solved Threads: 1,416
>i prefer to just make my site in some sort of pagebuilder
Even easier. A page builder should have a function that lets you insert a rollover without even touching the code. Unless it's a super cheap builder provided by a free web host. ;) In that case you'll pretty much have to get your hands a little dirty.
>html code(or is it javascript)
It's both. a href and img src are HTML tags. The onMouseOver and onMouseOut events and properties are Javascript.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
Everywhere my code uses on.gif, you use down.gif and everywhere I used off.gif, you use up.gif. It's a simple substitution, then where I have "link", change it to "http://www.whateveryoururlis.com". The a href tag creates a hyperlink, like the following:
www.google.com
The img src tag displays an image and by nesting it in an a href tag, you create an image hyperlink where the link is an image rather than simple text.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
>what else do i nned to change
It depends. Does it work when you paste it into your HTML file? I don't see anything wrong, so the only issue would be whether the link is valid or not.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401