How to make a rollover/hover button with Javascript?

Mar 3, 2006
113
0
0
On my website I want the picture (which is also a link) to change when someone puts the cursor on it. I have made both pictures, but I don't know Java. Can someone help me out?

EDIT: I made a hover button in FrontPage and copied the code and just changed the filenames so it has my pics. It seems to be working.
 

Isaiah

Senior member
May 31, 2000
453
0
0
Don't use Javascript, CSS is the best way to do image rollovers.

Try something like this:

a.class_name:link, a.class_name:visited, a.class_name:active {
color:#fff;
text-decoration:none;
background:#fff url(rollover.jpg) no-repeat;
}
a.class_name:hover {
color:#fff;
background:#fff url(rollover2.jpg) no-repeat;
}

Or even better just have one image that includes both images and have the css change the offset like this, that way you don't have to preload the images:

a.class_name:hover {
color:#fff;
background:#fff url(rollover.jpg) no-repeat -200px 0px;
}


If you don't know any css, I suggest you do a quick search on google at read up on it, because it will help you understand what you are doing... not just blindly copy and pasting code

I've attached a some more CSS code... you should be able to copy and paste it(changing the colors, images and class name to fit your needs

-Isaiah
 
Mar 3, 2006
113
0
0
Ok thanks. I have to go to work right now, so I can't test this out yet, but does the image have to take up the whole cell of the table? I just see the word background, so I'm wondering.
 

Isaiah

Senior member
May 31, 2000
453
0
0
No, if you look at the code I attached it should say:
width:200px;
height:100px;

That is where you set the site of the image that is going to be displayed.

If this is for a menu you might want to think about using <ul>(list) not a table.

You might want to take a look at this site: http://www.projectseven.com/tutorials/css/uberlinks/

-Isaiah
 
Mar 3, 2006
113
0
0
Yes, it's for a menu, but there's only 3 pics (6 if you include the rollover images), and that uberlinks thing doesn't really apply to what I'm doing.

Now I know basic CSS, like to format my text and stuff, but I don't quite understand this rollover CSS.

So could maybe help me a little more, and use this example: normal image = img1.jpg, rollover image = img2.jpg, height= 50, width = 100.

Because I copied your code and pasted it into Frontpage to see what it would look like, and it just showed up as text when I previewed it. So PLEEEEASE can you help me some more? *sad puppy face*
 

Isaiah

Senior member
May 31, 2000
453
0
0
Can you show me an example of what you have done so far?

Here is an example I made using the css code I gave you: http://www.iitechconsulting.com/example.html

How do you want your menu to look?

You can have two image files like you are talking about, but I like to combine them into one file, and just change the display offset in the css code(see example) that way you don't have to worry about preloading or the image taking a while to load when you roll your mouse over it.
 
Mar 3, 2006
113
0
0
Alright, well I finally got the Javascript one to work, so I'm not going to worry about doing it with CSS, but thank you so much for all the help. If you really want to see it, it's

http://www.fpsgaming.us

I'm hoping to make some money with AdSense, that's why I made the site. And it might look like a bad layout to some, but since it's my first one and I made it by myself, I kind of like it.
 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |