Set Interval in JavaScript Object (IE)
Can anyone tell me why my setInterval code below doesn't work in IE.[code]Scroller = {v_intval : null,
init : function( selector, speed ) {
if (typeof(speed)=='underfind') {
speed = 50;
}
var parentBox = $(selector);
parentBox.find('.vscroller-down')
.bind('mouseover',function(event){ Scroller.down( selector, speed ); })
.bind('mouseout',function(event){ Scroller.stop(); });
parentBox.find('.vscroller-up')
.bind('mouseover',function(event){ Scroller.up( selector, speed ); })
.bind('mouseout',function(event){ Scroller.stop(); })
.css('display', 'none');
$('div.parent').scrollTop(0);
},
move: function( mode, selector) {
var parentBox = $(selector);
var box = $('div.vscroller-mainbody');
var parent = $('div.parent');
var max = box.height() - parent.height();
$('#debug').html( max+', '+parent.scrollTop()+'<br/>');
if (mode == 'down') {
if ( parent.scrollTop() == max ) {
parentBox.find('.vscroller-down').css('display', 'none');
}
else {
parentBox.find('.vscroller-up').css('display', '');
parent.scrollTop(parent.scrollTop() + 1 );
}
}
else {
if ( parent.scrollTop() == 0) {
parentBox.find('.vscroller-up').css('display', 'none');
}
else {
parentBox.find('.vscroller-down').css('display', '');
parent.scrollTop(parent.scrollTop() - 1 );
}
}
},
up: function( selector, speed ) {
Scroller.v_intval = setInterval("Scroller.move('up', '"+ selector +"')", speed );
},
down: function( selector, speed ) {
Scroller.v_intval = setInterval("Scroller.move('down', '"+ selector +"')", speed );
},
stop: function(){
window.clearInterval(Scroller.v_intval);
},
'dummy' : ''
};[/code] [code]window.setInterval(
function(){
Scroller.move('case', selector)
}, speed ); [/code]
頁:
[1]