How to make mouseover codes

Album

New Member
Messages
348
Reaction score
0
Points
0
isn't there a type of code you can use to make it so that when someone moves the cursor over a link or a image, it'll change?

Can someone please teach me what the code for this is?

example: There is a button (button.jpg) and I want for it to change to button2(button2.jpg) when someone's cursor is on top of it . How can I make this possible?
 

clareto

New Member
Messages
250
Reaction score
0
Points
0
You can do it with Javascript or Css

If you want javascript, Macromedia Dreamweaver MX generates a good code.
Css can do the same, I really dont know how implemented is it in recent browsers.

I did found useful information making the google search "css image rollover tutorial"
 

Bryon

I Fix Things
Messages
8,149
Reaction score
101
Points
48
You will need to use event attributes in HTML.

Give me a few minutes so I can get you the few lines of code.
 

mattspec

Active Member
Messages
1,390
Reaction score
0
Points
36
javascript is a really easy way of doing it, its all ove if you just want to google it
 

Bryon

I Fix Things
Messages
8,149
Reaction score
101
Points
48
Sorry I had to get off for a bit.. I see you found a way to do it.

I was going to give you this:

Code:
<script type="text/javascript">


// For each set of images, add these lines, incrementing each number at the end of the line for the pair.
image1 = new Image();
image1.src = "image_on.gif";

image2 = new Image();
image2.src = "image_off.gif";

</script>


<a href="html.html" onmouseover="document.scrollover1.src=image1.src" onmouseout="document.scrollover1.src=image2.src">
<img src="image_off.gif" name="scrollover1">
</a>
 

Album

New Member
Messages
348
Reaction score
0
Points
0
Thanks NedrevN :)

That also helps since thats a slightly different way of doing it
 

Bryon

I Fix Things
Messages
8,149
Reaction score
101
Points
48
Yep. Your welcome. :-D

They basically are the same thing.. lol.
 
Last edited:

clareto

New Member
Messages
250
Reaction score
0
Points
0
mmm... I've tried with the macromedia preload images function, and using the trick to put the images with 1px width and height, or putting them in an invisible layer. In fact, the rollover works, but the status bar of the browser says "transferring data from .... ", or "waiting for...". I think a small rollover may become a big bandwith eater!!!
 

Bryon

I Fix Things
Messages
8,149
Reaction score
101
Points
48
Once the image loads, it *should* be cached by the browser, thus not loading over and over again everytime you "scroll over" the image.

Also, the way I have the scrollover images set up preloads the images already. :-D
 
Top