JavaScript funktioniert im Firefox nicht

Kopfballstar

Erfahrenes Mitglied
Hallo,
ein JavaScript funktioniert bei mir im Firefox nicht, im IE schon. Kann den Fehler leider nicht finden.

Code:
pos=0; timer=null; sprung=2; zeit=1; 				
function scrollitup() { 
	if(document.getElementById("main_text")) { 
		max=document.getElementById("main_text").offsetHeight-200;
			if(pos<max) { 
				pos=pos+sprung;
				document.getElementById("main_text").style.posTop=pos * (-1);
				<!--alert(document.getElementById("main_text").style.posTop);
			}
	}
	timer=window.setTimeout("scrollitup()",zeit);

}
 
Probier mal Folgendes:
Code:
var pos=0, timer=null, sprung=2, zeit=1;
 				
function scrollitup()
{
	if( document.getElementById("main_text") ) {
		var max = document.getElementById("main_text").offsetHeight - 200;
			if( pos < max ) {
				pos = pos + sprung;
				document.getElementById("main_text").style.posTop = (pos * -1) + "px";
				document.getElementById("main_text").style.top    = (pos * -1) + "px";
				// alert(document.getElementById("main_text").style.posTop);
			}
	}
	var timer = window.setTimeout("scrollitup()", zeit);
}
 
Kommentare werden in Javascript mit zwei Slashes maskiert:

Code:
// alert(document.getElementById("main_text").style.posTop);
 
Zurück