Hi-
I am trying to use setInterval to call a method within an object and
have not had any luck. I get "Object doesn't support this property or
method" when I execute the following code. What I am doing wrong?
Your help will be much appreciated.
Thanks
<script language="Javas cript">
function someObject(){
}
someObject.prot otype.showNext = function(){
alert('listenin g...');
}
//i've tried this:
someObject.prot otype.startList ening = function(){
this.interval = setInterval('th is.showNext()', 2000);
}
//and this:
someObject.prot otype.startList ening = function(){
this.interval = setInterval(thi s.showNext(), 2000);
/*
is 'this.showNext( )' referencing setInterval and not my object?
*/
}
var x = new someObject();
x.startListenin g();
</script>
I am trying to use setInterval to call a method within an object and
have not had any luck. I get "Object doesn't support this property or
method" when I execute the following code. What I am doing wrong?
Your help will be much appreciated.
Thanks
<script language="Javas cript">
function someObject(){
}
someObject.prot otype.showNext = function(){
alert('listenin g...');
}
//i've tried this:
someObject.prot otype.startList ening = function(){
this.interval = setInterval('th is.showNext()', 2000);
}
//and this:
someObject.prot otype.startList ening = function(){
this.interval = setInterval(thi s.showNext(), 2000);
/*
is 'this.showNext( )' referencing setInterval and not my object?
*/
}
var x = new someObject();
x.startListenin g();
</script>
Comment