473,386 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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 4562
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Generale Cluster | last post by:
Hello, where can I find an horizontal scroller where I can set the scrolling direction from left to right? Thank you -- elimina unsampdoriano per rispondere via email
3
by: Razvan | last post by:
Hello, Can somebody recommend me a Java Script scroller that can scroll an i-frame ? I tried the Tigra scroller (www.softcomplex.com/products/tigra_scroller/) but sometimes it does not...
6
by: sasan3 | last post by:
My mouse wheel scroller works in all Access windows except Visual Basic sub-windows. I am running Access 2002. Any ideas? Thanks. S
8
by: marco | last post by:
Hi ! I have this part of code and i can not find out why the scroller is starting from left to right instead RIGHT to LEFT. This is the main part and the scroller is working fine but from the...
5
by: PythonistL | last post by:
I am a newbie with Javascript. I have this simple script for scrolling text <HTML> <HEAD> <TITLE>Scrolling Message Script</TITLE> <SCRIPT language="JavaScript"><!-- var msg = 'My scrolling...
5
by: eholz1 | last post by:
Hello Group, I am developing a web site using CSS. I have a div that has a vert scroll bar in it. The div works just fine (scroll up and down, etc). I have regular text (using <ptags) in the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.