Weiß ich leider nicht; ich habe das bisher so verwendet. Zum Beispiel in einer kleinen Funktion zum scrollen des Inhalts eines HTML-Elements:
/**
* set up interval (or stop it) to scroll an element (using the mover()-function)
*
* @param String elemId - id of HTML-element, that should be scrolled
* @param int direction - the direction to scroll (0 => UP; 1 => DOWN)
* @param boolean status - selects wether to start or stop the interval;
* ('true' on mouseover, 'false' on mouseout)
*/
function scroll(elemId, direction, status, speed)
{
elem = document.getElementById(elemId);
if(status == true) {
// using anonymous function to send object as paramter, set interval-speed here
activeScroller[elemId] = window.setInterval(function(){mover(elem, direction);}, 100);
}
else {
window.clearInterval(activeScroller[elemId]);
}
}
/**
* scroll down an given HTML-element into direction by 10 Pixel
*
* @param Element elem - the given HTML-element (as JS-object)
* @param int direction - the direction to scroll (0 => UP; 1 => DOWN)
*/
function mover(elem, direction) {
if(direction == 0) {
elem.scrollTop -= 10;
}
else {
elem.scrollTop += 10;
}
}
<img src="arr_up.gif" alt="scroll up" onmouseover="scroll('mytextbox', 0, true);" onmouseout="scroll('mytextbox', 0, false);" />
<img src="arr_down.gif" alt="scroll down" onmouseover="scroll('mytextbox', 1, true);" onmouseout="scroll('mytextbox', 1, false);" />
Bis denn dann,
Thomas