napisałem taki kodzik, przesuwający tekst w dół:
var scrollSpeed = 1
var scrolls = 0;
function initScroll(id) {
var marquee = document.getElementById(id)
if(marquee.offsetHeight > marquee.parentNode.offsetHeight) {
scrolls++
resetPosition(id)
scrollDown(id)
}
}
function scrollDown(id) {
var marquee = document.getElementById(id)
marquee.style.top = parseInt(marquee.style.top) - scrollSpeed
setTimeout("scrollDown('" + id + "')", 50)
}
function resetPosition(id) {
var marquee = document.getElementById(id)
marquee.style.top = 0 + marquee.parentNode.offsetHeight
var timeOut = (((marquee.offsetHeight + marquee.parentNode.offsetHeight) * 50) / scrollSpeed) + (scrolls * 100)
setTimeout("resetPosition('" + id + "')", timeOut)
}
wszystko działa, tylko czy nie dałoby się zrobić tego bez wywolywania za każdym razem getElementById() i zliczania zmiennej timeOut?