Max1989: Schleife mit set timeout

Beitrag lesen

hey
danke für deine antwort.
entweder bin ich zu blöd dafür, oder ich hab was übersehen.

ist das so richtig? (funktioniert leider immer noch nicht)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
        <title>Opacity</title>
<style type="text/css" media="screen">
div#optest {
        width: 800px;
        height:800px;
        background-color:#FF0000;
        filter:alpha(opacity=100);
        -moz-opacity:1.0;
        KhtmlOpacity: 1.0;
}
</style>

<script type="text/javascript" language="JavaScript">
Function.prototype.Timer = function (interval, calls, onend) {
  var count = 0;
  var payloadFunction = this;
  var startTime = new Date();
  var callbackFunction = function () {
    return payloadFunction(startTime, count);
  };
  var endFunction = function () {
    if (onend) {
      onend(startTime, count, calls);
    }
  };
  var timerFunction = function () {
    count++;
    if (count < calls && callbackFunction() != false) {
      window.setTimeout(timerFunction, interval);
    } else {
      endFunction();
    }
  };
  timerFunction();
};

function fade (id, actOpac, endOpac, step) {
 var obj = document.getElementById(id);
 var o = actOpac;
 function opacity () {
  o += (actOpac > endOpac) ? -step : step;
  if(typeof obj.style.filter != 'undefined')
  obj.style.filter = 'alpha(opacity=' + o  + ')';
  else if( typeof obj.style.opacity != 'undefined')
  obj.style.opacity = o / 100;
  return !(Math.abs(endOpac - o) < step);
 }

Function.prototype.Timer(20, 100);
};

</script>
</head>
<body>
 <div id="optest"></div>
 <a href="#" onclick="fade('optest', 100,0,10);">Fade out</a>
<a href="#" onclick="fade('optest', 0, 100, 10);">Fade in</a>
</body>
</html>

danke für deine geduld und hilfe!

lg
max