Click to See Complete Forum and Search --> : rollover on Javascript


nicoletta
06-10-2003, 02:52 PM
I have a few difficulties in trying to find the right code for the rollover, can anyone help ?

Vladdy
06-10-2003, 03:09 PM
That is CSS job, not JS.

.someClass
{ /* your styles here */
}

.someClass:hover
{ /* hover styles here */
}

brendandonhue
06-10-2003, 03:41 PM
You want an image rollover?

Using CSS sounds better than using JS to me, but im not sure how Vladdy's code works, so heres the javascript:

<img src="firstimage.gif" onmouseover=this.src="secondimage.gif" onmouseout=this.src="firstimage.gif">

midiman
06-10-2003, 08:32 PM
didn't know you could do that without preloading in the head like everyone else always shows it. thanks!

brendandonhue
06-10-2003, 08:34 PM
If you have multiple rollovers on one page-you should preload or it will look bad on dial up.

midiman
06-10-2003, 09:57 PM
agreed...preloading is important, but i just thought it was neat-o that you could load them right there like that.

quick question - what the heck is wrong with this? IE 6.0 is coming up with a "; expected" at the eval() line. just a simple rollover...:


portfolio_on = new Image(155,44)
portfolio_on.src = "images/portfolio_on.gif"
family_on = etc. etc.. etc..

function changeimage(img) {
eval(img + ".src = " + img + "_on.src")
}

IN BODY:

<IMG SRC="images/home_07.gif" ID="portfolio" WIDTH=155 HEIGHT=44 onmouseover="changeimage(portfolio)">