I wrote a javascript to scroll the contents inside of a span tag. I works with IE 6.0. But, When I tried it on mozilla and firefox. The browsers just halted(not responding). so, I had to kill those browsers' processes. My code is here:
function PbSpan(objId,step,delay)
{
//Properties
this.spanObj = document.getElementById(objId);
this.pixelSize = step;
this.intervalDelay = delay;
this.intervalId = 0;
//Pre-settings
this.spanObj.parentObj = this; //user-defined property for span object
this.spanObj.style.overflow = "hidden";
this.spanObj.innerHTML = "<table cellpadding=0 cellspacing=0 border=0 width=100>"+
"<tr><td>"+this.spanObj.innerHTML + "</td></tr>"+
"</table>";
this.spanObj.scrollTop=0;
while(this.spanObj.scrollHeight <
parseInt(this.spanObj.style.height)*2)
{
this.spanObj.innerHTML += this.spanObj.innerHTML;
}
//Start to play scrolling
this.intervalId =
setInterval(
'posCheck("'+this.spanObj.id+'");'+
'getObj("'+this.spanObj.id+'").scrollTop+='+this.pixelSize,
this.intervalDelay);
this.spanObj.onmouseover = mouseOverHandler;
this.spanObj.onmouseout = mouseOutHandler;
}
//Event Handlers
function mouseOverHandler()
{
clearInterval(this.parentObj.intervalId);
}
function mouseOutHandler()
{
this.parentObj.intervalId =
setInterval(
'posCheck("'+this.id+'");'+
'getObj("'+this.id+'").scrollTop+='+this.parentObj.pixelSize,
this.parentObj.intervalDelay);
}
//Required functions
function posCheck(str)
{
var obj = getObj(str);
if((parseInt(obj.style.height) + obj.scrollTop) >= obj.scrollHeight)
{
obj.scrollTop = parseInt(obj.style.height); // one pixel of mis-position expected.
}
}
function getObj(str)
{
return document.getElementById(str);
}
At least, the browsers should show an error message. they just stopped processing.
Thank you for reading this.
function PbSpan(objId,step,delay)
{
//Properties
this.spanObj = document.getElementById(objId);
this.pixelSize = step;
this.intervalDelay = delay;
this.intervalId = 0;
//Pre-settings
this.spanObj.parentObj = this; //user-defined property for span object
this.spanObj.style.overflow = "hidden";
this.spanObj.innerHTML = "<table cellpadding=0 cellspacing=0 border=0 width=100>"+
"<tr><td>"+this.spanObj.innerHTML + "</td></tr>"+
"</table>";
this.spanObj.scrollTop=0;
while(this.spanObj.scrollHeight <
parseInt(this.spanObj.style.height)*2)
{
this.spanObj.innerHTML += this.spanObj.innerHTML;
}
//Start to play scrolling
this.intervalId =
setInterval(
'posCheck("'+this.spanObj.id+'");'+
'getObj("'+this.spanObj.id+'").scrollTop+='+this.pixelSize,
this.intervalDelay);
this.spanObj.onmouseover = mouseOverHandler;
this.spanObj.onmouseout = mouseOutHandler;
}
//Event Handlers
function mouseOverHandler()
{
clearInterval(this.parentObj.intervalId);
}
function mouseOutHandler()
{
this.parentObj.intervalId =
setInterval(
'posCheck("'+this.id+'");'+
'getObj("'+this.id+'").scrollTop+='+this.parentObj.pixelSize,
this.parentObj.intervalDelay);
}
//Required functions
function posCheck(str)
{
var obj = getObj(str);
if((parseInt(obj.style.height) + obj.scrollTop) >= obj.scrollHeight)
{
obj.scrollTop = parseInt(obj.style.height); // one pixel of mis-position expected.
}
}
function getObj(str)
{
return document.getElementById(str);
}
At least, the browsers should show an error message. they just stopped processing.
Thank you for reading this.