Single Paradox
08-18-2005, 01:14 AM
here is my code:
<html>
<head>
<script>
var Timer1;
var Timer2;
var google1=10;
var google2=10;
function fadeIn(ID,which,which2){
if(which2*2<=80){
clearTimeout("Timer"+which);
document.getElementById(ID).filters.alpha.opacity=which2*2;
which2++;
window.status=document.getElementById(ID).filters.alpha.opacity;
window["Timer"+which]=setTimeout(function() {fadeIn(ID,which,which2)},0);
}else{
clearTimeout("Timer"+which);
}
}
function fadeOut(ID,which,which2){
if(which2*2>=20){
clearTimeout("Timer"+which);
document.getElementById(ID).filters.alpha.opacity=which2*2;
which2--;
window.status=document.getElementById(ID).filters.alpha.opacity;
window["Timer"+which]=setTimeout(function() {fadeOut(ID,which,which2)},0);
}else{
clearTimeout("Timer"+which);
}
}
</script>
</head>
<body onload="window.status=document.getElementById('fade1').filters.alpha.opacity;" background="http://www.singleparadox.com/images/bg.gif">
<br><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR>
<div id="fade1" onmouseover="fadeIn(this.id,1,google1)" onmouseout="fadeOut(this.id,1,google1);" style="filter:alpha(opacity=20);border:1px solid black;height:100px;width:500px;background:blue;">
Some Text Some Text Some Text
</div><br>
<div id="fade2" onmouseover="fadeIn(this.id,2,google2)" onmouseout="fadeOut(this.id,2,google2);" style="filter:alpha(opacity=20);border:1px solid black;height:100px;width:500px;background:blue;">
Some Text Some Text Some Text
</div>
</body>
</html>
It is in internet explorer only at this time because I want to get it working before I solve X-browser things. I have two problems with this code. One is that it doesn't fade out, it just goes straight to 20% opacity. The other problem is that when I move my mouse over one div and then over the other really quick, the first div doesn't fade out (or at least go straight to 20%). Because I am using different variables each time the functions are called, shouldn't it not clash with a seperate calling of the function? Did I reference the variables to be called incorrectly?
In short I want it to work just like the code shown here: http://www.dynamicdrive.com/dynamicindex4/highlightgrad2.htm
But I am stubborn and proud and I don't want to copy another code.
<html>
<head>
<script>
var Timer1;
var Timer2;
var google1=10;
var google2=10;
function fadeIn(ID,which,which2){
if(which2*2<=80){
clearTimeout("Timer"+which);
document.getElementById(ID).filters.alpha.opacity=which2*2;
which2++;
window.status=document.getElementById(ID).filters.alpha.opacity;
window["Timer"+which]=setTimeout(function() {fadeIn(ID,which,which2)},0);
}else{
clearTimeout("Timer"+which);
}
}
function fadeOut(ID,which,which2){
if(which2*2>=20){
clearTimeout("Timer"+which);
document.getElementById(ID).filters.alpha.opacity=which2*2;
which2--;
window.status=document.getElementById(ID).filters.alpha.opacity;
window["Timer"+which]=setTimeout(function() {fadeOut(ID,which,which2)},0);
}else{
clearTimeout("Timer"+which);
}
}
</script>
</head>
<body onload="window.status=document.getElementById('fade1').filters.alpha.opacity;" background="http://www.singleparadox.com/images/bg.gif">
<br><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR>
<div id="fade1" onmouseover="fadeIn(this.id,1,google1)" onmouseout="fadeOut(this.id,1,google1);" style="filter:alpha(opacity=20);border:1px solid black;height:100px;width:500px;background:blue;">
Some Text Some Text Some Text
</div><br>
<div id="fade2" onmouseover="fadeIn(this.id,2,google2)" onmouseout="fadeOut(this.id,2,google2);" style="filter:alpha(opacity=20);border:1px solid black;height:100px;width:500px;background:blue;">
Some Text Some Text Some Text
</div>
</body>
</html>
It is in internet explorer only at this time because I want to get it working before I solve X-browser things. I have two problems with this code. One is that it doesn't fade out, it just goes straight to 20% opacity. The other problem is that when I move my mouse over one div and then over the other really quick, the first div doesn't fade out (or at least go straight to 20%). Because I am using different variables each time the functions are called, shouldn't it not clash with a seperate calling of the function? Did I reference the variables to be called incorrectly?
In short I want it to work just like the code shown here: http://www.dynamicdrive.com/dynamicindex4/highlightgrad2.htm
But I am stubborn and proud and I don't want to copy another code.