TeamPhotoshop
Reviews, updates and in depth guides to your favourite mobile games - AppGamer.com
Forum Home Latest Posts Search Help Subscribe

Need some help on simple Javascript

Page: 1 Reply
Feb 3rd 2003#88845 Report
Member since: Feb 1st 2003
Posts: 29
I'm an idiot in Javascript, and I remember that I've used a script that lets image fade in and fade out while mouseover. Do anyone know the script or, is there any other way for that effect?
Reply with Quote Reply
Feb 3rd 2003#88849 Report
Member since: Apr 1st 2002
Posts: 1487
Paaaaavooooo?

:D

Well here is the code that goes in the head of the document:
[PHP]script language="JavaScript" type="text/javascript">

fades = new Object();
timers = new Object();

function settrans(object, transparent){
object.filters.alpha.opacity = transparent;
}

function fademeout(object, transparent){

fadespeed = 50;
multiply = 10;

if (!document.all)
return
if (object != "[object]"){ return; }
clearTimeout(timers[object.sourceIndex]);
space = transparent-object.filters.alpha.opacity;

multiply = Math.min(-1 * space, multiply);
object.filters.alpha.opacity += -1 * multiply;

if (object.filters.alpha.opacity != transparent){
fades[object.sourceIndex] = object;
timers[object.sourceIndex] = setTimeout("fademeout(fades["+object.sourceIndex+"],"+transparent+")",fadespeed);
}

}
[/PHP]
And here is the code you would use:
[PHP]
onMouseOver="document.images['i1'].src='homea.gif'"

onMouseOut="document.images['i1'].src='home.gif'">

alt="Home" width="150" height="25" style="filter:alpha(opacity=25)" onmouseover="settrans(this,100)" onmouseout="fademeout(this,25)">
[/PHP]

But I got this from other sites, Paavo might be able to come up with a more efficient way of doing this.

PS: I know I screwed up the table. Live with it. :p :D
Reply with Quote Reply
Feb 3rd 2003#88850 Report
Member since: Feb 1st 2003
Posts: 29
um...what's the "homea.gif"?
Reply with Quote Reply
Feb 3rd 2003#88851 Report
Member since: Mar 20th 2001
Posts: 3367
home .. mouseovers becomes homea
Reply with Quote Reply
Feb 3rd 2003#88853 Report
Member since: Nov 29th 2002
Posts: 69
Reply with Quote Reply
Feb 3rd 2003#88854 Report
Member since: Nov 29th 2002
Posts: 69
Anyway if you are still interested in javascript here´s another tut

HERE
Reply with Quote Reply
Page: 1 Back to top
Please login or register above to post in this forum