Hey,
ik zou graag binnen mijn functie divMinusOne, divMinusOne steeds willen aanroepen totdat de if false is. Alleen dit werkt niet omdat de functie binnen een functie staat. Het gaat om deze regel:
window.setTimeout('divMinusOne()', 1);
Hieronder een klein gedeelte van de code.
function toggle(or, id){
this.active = 0;
this.height = 0;
this.name = id;
this.or = or;
this.divMinusOne = function () {
if(this.height >= 0) {
this.height = this.height - 1;
document.getElementById(this.name).style.height=this.height + 'px';
window.setTimeout('divMinusOne()', 1);
} else {
document.getElementById(this.name).style.display="none";
}
}
}
ik heb een oplossing gevonden danku
<script type="text/javascript">
function timeoutExample(){
return this;
}
timeoutExample.prototype = {
f : function(te) {
alert("Yahar!");
settimeout(function(){te.f(te);}, 50);
}
}
var foo=new timeoutExample();
foo.f(foo);
</script>
478 views