The Enchanted Cave 2
Delve into a strange cave with a seemingly endless supply of treasure, strategically choos
4.34 / 5.00 31,296 ViewsGhostbusters B.I.P.
COMPLETE edition of the interactive "choose next panel" comic
4.07 / 5.00 10,082 ViewsHey dose any one know how I can program javascript to make images fade in and out when I hover over Hyperlinks?
So like there is a menu along the top of the page and each time I hover over a hyperlink in the menu the image that is somewhere else on the page will change?
I would really like some help on this.
(Do not suggest me to do it in flash I know it would be easier but I am not aloud to use flash in this project)
It would be pointless doing it in flash as flash is seporate from the DOM and you would need to use some sort of JS interface to communicate the mouseover event into flash in order for flash to do something.
You can use fadeIn to achieve this effect quite easily.
At 8/10/10 08:54 PM, Jon-86 wrote: You can use fadeIn to achieve this effect quite easily.
Do this first. If you don't know how to use jquery (or don't want to), you can do something like what I did below (I hacked it together quickly, doesn't work in IE).
window.fading = null;
function fadeInit(id,fadein)
{
clearTimeout(window.fading);
elem = document.getElementById(id);
v=parseFloat(elem.style.opacity);
if(fadein&&v<1 || !fadein&&v>0)
fade(elem,v,fadein?.1:-.1);
}
function fade(elem,now,speed)
{
elem.style.opacity = (now+speed);
if(speed>0&&now<1 || speed<0&&now>0)
window.fading =
setTimeout("fade(elem,"+(now+speed)+","+speed+")",10);
else
clearTimeout(window.fading);
}
...
<img style="opacity:1" src="img.jpg" id="myimg">
<a onmouseover="fadeInit('myimg',true)" href="javascript:void">Fade in</a>
<br>
<a onmouseover="fadeInit('myimg',false)" href="javascript:void">Fade out</a> At 8/12/10 05:15 PM, fourthfrench wrote:At 8/10/10 08:54 PM, Jon-86 wrote: You can use fadeIn to achieve this effect quite easily.Do this first. If you don't know how to use jquery (or don't want to), you can do something like what I
I personally think it's a much better idea to just use jQuery, as it would also work in IE, and eventually, using jQuery all the time will open up a much more FUN javascript programming experience.
I've personally kept from using jQuery for a long while, as I was being a purist, doing everything myself, basically. When I decided to try it out, I felt dumb for not doing so right away.
At 8/12/10 08:33 PM, Mich wrote: I personally think it's a much better idea to just use jQuery
I completely support using a framework instead. I just wanted to give the guy another option, since switching to a framework is a little daunting.