View Full Version : Anyone know javascript
spadanko
07-25-2007, 11:38 AM
I gotta add something ehre for work, rollover a link, and an image appears. the image changes evrytime you roll over the link... anyone out there can help?
JustJon
07-25-2007, 12:01 PM
That is the most basic javascript you can find. We even use it on RonFez.Net. (scope the buttons on the left side)
Just google it up and you'll find the code.
spadanko
07-25-2007, 12:07 PM
well, i know how to do it be rolling over an image and it changing, i need to roll over a link, and have an image appear. I think it may be able to be done in CSS.
JustJon
07-25-2007, 01:01 PM
Where does the image need to appear? Over the link? Like the pictures over the names on Gmail? Or like the little XBox icon under my name?
Then you just need to javascript a link over to make a hidden div visible and set the location. Not too hard, just need to find and edit existing code for that. Like off our site for the XBox thing. (I changed it from a link to an image when I installed it)
feralBoy
07-25-2007, 01:05 PM
I'm not exactly sure what you want to do, but if you find an example of what you want to do, you can just steal the code. JS isn't compiled or anything, so you can view the source of the webpage, and the code will either be there, or it will show you a link to where the source is, usually a .js file somewhere on the server.
celery
07-25-2007, 01:12 PM
The easiest way is probably to use the :hover pseudo-selector applied to the element you want. You can probably accomlish the effect you want using pure CSS and no JS. PM me if you need more info.
STYLE:
a:hover { background: url(image_hover.gif); }
MadMatt
07-25-2007, 01:33 PM
The easiest way is probably to use the :hover pseudo-selector applied to the element you want. You can probably accomlish the effect you want using pure CSS and no JS. PM me if you need more info.
STYLE:
a:hover { background: url(image_hover.gif); }
But how do you do that with multiple images? He wants a "different" image to appear each time.
[sorry to horn in, but this interests me]
celery
07-25-2007, 01:39 PM
But how do you do that with multiple images? He wants a "different" image to appear each time.
[sorry to horn in, but this interests me]
Oh, I think I misunderstood - when he said "the image changes everytime you rollover the link", I thought he just meant it would just be a standard rollover. To make it a different image every time is definitely going to take some custom JS - probably storing all the image names in an array, cycling through onMouseOver and repeating when you've gone through all of them.
JustJon
07-25-2007, 01:41 PM
What if he wants a random image?
JPMNICK
07-25-2007, 01:43 PM
What if he wants a random image?
use cgispy?
celery
07-25-2007, 01:56 PM
What if he wants a random image?
I'd use a function to pull a random element from the array - so the whole thing would look something like this:
var images = new Array(3)
images[0] = '1.gif';
images[1] = '2.gif';
images[2] = '3.gif';
Array.prototype.random = function( r ) {
var i = 0, l = this.length;
if( !r ) { r = this.length; }
else if( r > 0 ) { r = r % l; }
else { i = r; r = l + r % l; }
return this[ Math.floor( r * Math.random() - i ) ];
};
function switchImage() {
document.getElementById('linkid').style.background = 'url(' + images.random() + ')';
}
spadanko
07-26-2007, 08:17 AM
yeah, so hear is what exactly I need.
i work for tvguide... we have a verticle list of Soap shows. there is an image to the left, and down about 100 px or so... when you roll over the show name, we want taht shows photo to appear. not random photos... ones that we specified....
thanks for your help fellas
JustJon
07-26-2007, 09:24 AM
That's very easy.
Use a standard image flipper, but set all the flips to target the single image you want to flip. You set the show name or whatever in the href MouseOver flag and when they move over it, it will flip the image on the left side instead.
spadanko
07-26-2007, 09:33 AM
That's very easy.
Use a standard image flipper, but set all the flips to target the single image you want to flip. You set the show name or whatever in the href MouseOver flag and when they move over it, it will flip the image on the left side instead.
awesome.. thanks JustJon
StupidGirlllll
07-26-2007, 09:35 AM
Anyone know javascript
No I am still trying to meet his brother Browser.
JPMNICK
07-26-2007, 12:01 PM
That's very easy.
Use a standard image flipper, but set all the flips to target the single image you want to flip. You set the show name or whatever in the href MouseOver flag and when they move over it, it will flip the image on the left side instead.
the man is a genius
JustJon
07-26-2007, 12:40 PM
the man is a genius
Quoted for truth
spadanko
07-26-2007, 12:55 PM
just used a onmouseover.... pretty simple actually... was making it more complicated tehn it needed to be
celery
07-26-2007, 12:58 PM
just used a onmouseover.... pretty simple actually... was making it more complicated tehn it needed to be
Well, I feel like a dork for writing a code sample - though, I was bored at work.
Glad you got it working...
JustJon
07-26-2007, 01:04 PM
just used a onmouseover.... pretty simple actually... was making it more complicated tehn it needed to be
Isn't that what I said? :smoke:
vBulletin® v3.7.0, Copyright ©2000-2024, Jelsoft Enterprises Ltd.