469,921 Members | 2,103 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,921 developers. It's quick & easy.

Text Scroller: scrolling stops in Firefox

Hi,

I have a script which works in both IE but is sluggish in Firefox.
The script is a simple text scroller.
It works perfectly in IE however in Firefox, the text scroll slower and
eventually just stops.

I would aprechiate it someone could look at the code below and maybe
see where the problem is?

Thank you in advance,
Micky

/************************************************** *******************/
<html>
<head>
<title>test</title>

<head></head>
<BODY >

<table bgcolor="00000" width="752" cellpadding="0" cellspacing="0"
border="0">

<tr>
<td>

<SCRIPT>

var text=new Array()
text[0]="testtesttest"
text[1]=" testtest test test test "
text[2]=" testtest test test test"

// Add a link for each message
var textlink=new Array()
textlink[0]="http://"
textlink[1]="http://"
textlink[2]="http://"

// Add a target for each link
// Possible values are "_blank", "_self", "_top", "_parent"
var texttarget=new Array()
texttarget[0]="_blank"
texttarget[1]="_blank"
texttarget[2]="_blank"

............
var translayersmax=Math.floor(translayerszone/translayerswidth)
var translayersleftpos=0
var translayersopacity=100
var translayersfactor=100/translayersmax
var translayerswidthall=translayersmax*translayerswidt h
var ie=document.all?1:0
var ns6=document.getElementById&&!document.all?1:0
var ns4=document.layers?1:0
var browserinfos=navigator.userAgent
var opera=browserinfos.match(/Opera/)

getcontent()
function getcontent() {
...
<!-- table for scroll -->
if (ie || ns6) {
document.write('<table cellpadding=0 cellspacing=0 border=0
height='+textheight+' width='+textwidth+'><tr><td>');
document.write('<div id="marker" style="position:relative;
width:'+textwidth+';
height:'+textheight+'" ></div>');
document.write('</td></tr></table>')
if (ns6) {
var tablewidth=textwidth-2*textborder
var tableheight=textheight-2*textborder
}
else {
var tablewidth=textwidth
var tableheight=textheight
}
document.write('<div ID="roof" style="position:absolute;width:'
+tablewidth+'px;height:'+tableheight+'px;border-style:solid;border-width:'+
textborder+'px;border-color:'+textbordercolor+';background-color:'+textbgcolor+';
visibility:hidden;overflow:hidden" onMouseOver="setscrollready(0)"
onMouseOut="setscrollready(1)">')
document.write('<span ID="ticker"
style="position:absolute;top:0px;left:0px;visibili ty:hidden">'+content+'</span>')

if (ie && !opera) {
for (i=0;i<=translayersmax;i++) {
document.write('<span ID="trans'+i+'"
style="position:absolute;top:0px;left:'+translayer sleftpos+'px;width:'+
translayerswidth+'px;height:'+tableheight+'px;back ground-color:'+textbgcolor+';filter:alpha(opacity='
+translayersopacity+');overflow:hidden"> </span>')
translayersleftpos+=translayerswidth
translayersopacity-=translayersfactor
}
translayersleftpos=tablewidth-translayersleftpos

for (ii=0;ii<=translayersmax;ii++) {
document.write('<span ID="trans'+ii+'"
style="position:absolute;top:0px;left:'
+translayersleftpos+'px;width:'+translayerswidth+' px;height:'+tableheight+'px;background-color:'+
textbgcolor+';filter:alpha(opacity='+translayersop acity+');overflow:hidden">
</span>')
translayersleftpos+=translayerswidth
translayersopacity+=translayersfactor
}
}

if (ns6 && !opera) {
for (i=0;i<=translayersmax-1;i++) {
document.write('<span ID="transleft'+i+'"
style="position:absolute;top:0px;left:'+
translayersleftpos+'px;width:'+translayerswidth+'p x;height:'+tableheight+'px;background-color:'
+textbgcolor+';-moz-opacity:'+
translayersopacity/100+';overflow:hidden"> </span>')
translayersleftpos+=translayerswidth
translayersopacity-=translayersfactor

if (translayersopacity<0) {translayersopacity=0.001}
}
translayersleftpos=tablewidth-translayersleftpos
translayersopacity=0.001
for (i=0;i<=translayersmax-1;i++) {
document.write('<span ID="transright'+i+'"
style="position:absolute;top:0px;left:'
+translayersleftpos+'px;width:'+
translayerswidth+'px;height:'+tableheight+'px;back ground-color:'+textbgcolor+';-moz-opacity:'
+translayersopacity/100+';"> </span>')
translayersleftpos+=translayerswidth
translayersopacity+=translayersfactor
}
}
document.write('</div>')
if (ns6) {
document.write('<span ID="tickersize"
style="position:absolute;top:0px;left:-5000px;
visibility:hidden">'+content+'</span>')
}
}

function doscroll(){
if (scrollready) {
if(ns4){
document.ticker.left+=-step;
if (document.ticker.left<document.marker.pageX+1*text border) {
document.ticker.clip.left+=step;
}

document.ticker.clip.right+=step;
if(document.ticker.left<-textcontentwidth+document.marker.pageX) {
document.ticker.left=textwidth+document.marker.pag eX-1*textborder;
document.ticker.clip.left=0
document.ticker.clip.right=0
}
}
if (ie) {
document.all.ticker.style.posLeft+=-step
if (document.all.ticker.style.posLeft<-textcontentwidth) {
document.all.ticker.style.posLeft=textwidth
}
}
//
if (ns6) {
document.getElementById('ticker').style.left=parse Int(document.getElementById('ticker').style.left)-step
if
(parseInt(document.getElementById('ticker').style. left)<-textcontentwidth)
{
document.getElementById('ticker').style.left=textw idth
}
}
timer=setTimeout("doscroll()",50)
}
else {
clearTimeout(timer)
}
}

function DL_GetElementLeft(eElement) {
var nLeftPos = eElement.offsetLeft;
var eParElement = eElement.offsetParent;
while (eParElement != null) {

nLeftPos += eParElement.offsetLeft;
eParElement = eParElement.offsetParent;
}
return nLeftPos;
}

function DL_GetElementTop(eElement) {
var nTopPos = eElement.offsetTop;
var eParElement = eElement.offsetParent;
while (eParElement != null) {

nTopPos += eParElement.offsetTop;
eParElement = eParElement.offsetParent;
}
return nTopPos;
}

function initscroller(){
......
if (ns6) {
textcontentwidth=document.getElementById('tickersi ze').offsetWidth
document.getElementById('roof').style.left=DL_GetE lementLeft(document.getElementById('marker'));
document.getElementById('roof').style.top=DL_GetEl ementTop(document.getElementById('marker'));
document.getElementById('ticker').style.left=textw idth
document.getElementById('ticker').clip='rect(0px,
'+textcontentwidth+'px, '+(textheight)+'px, 0px)';
document.getElementById('roof').style.visibility=" visible";
document.getElementById('ticker').style.visibility ="visible";
}
doscroll()
}

function setscrollready(whatanswer) {
if (whatanswer==1) {
scrollready=true
checkscroll()
}
else {
scrollready=false
}
}

function checkscroll() {
clearTimeout(timer)
if (scrollready) {
doscroll()
}
}
function reopenpage() {
history.go(0)
}
window.onresize=reopenpage
window.onload=initscroller
</script>

</td>
</td>
</tr>
</table>
</body></html>

Jul 30 '05 #1
1 4261
Mickey <mi************@gmail.com> wrote in message news:11*********************@g43g2000cwa.googlegro ups.com...
Hi,

I have a script which works in both IE but is sluggish in Firefox.
The script is a simple text scroller.
It works perfectly in IE however in Firefox, the text scroll slower and
eventually just stops.

I would aprechiate it someone could look at the code below and maybe
see where the problem is?

Thank you in advance,
Micky


<SNIP>
The code as posted references undeclared variables and therefore is not testable.
Layer movement is slower under Gecko browsers, so I would guess that the relevant function is being called too often.

--
Stephen Chalmers
Jul 31 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Generale Cluster | last post: by
3 posts views Thread by Razvan | last post: by
8 posts views Thread by marco | last post: by
5 posts views Thread by PythonistL | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.