M
Mickey
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*translayerswidth
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;visibility:hidden">'+content+'</span>')
if (ie && !opera) {
for (i=0;i<=translayersmax;i++) {
document.write('<span ID="trans'+i+'"
style="position:absolute;top:0px;left:'+translayersleftpos+'px;width:'+
translayerswidth+'px;height:'+tableheight+'px;background-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='+translayersopacity+');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+'px;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;background-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*textborder) {
document.ticker.clip.left+=step;
}
document.ticker.clip.right+=step;
if(document.ticker.left<-textcontentwidth+document.marker.pageX) {
document.ticker.left=textwidth+document.marker.pageX-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=parseInt(document.getElementById('ticker').style.left)-step
if
(parseInt(document.getElementById('ticker').style.left)<-textcontentwidth)
{
document.getElementById('ticker').style.left=textwidth
}
}
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('tickersize').offsetWidth
document.getElementById('roof').style.left=DL_GetElementLeft(document.getElementById('marker'));
document.getElementById('roof').style.top=DL_GetElementTop(document.getElementById('marker'));
document.getElementById('ticker').style.left=textwidth
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>
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*translayerswidth
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;visibility:hidden">'+content+'</span>')
if (ie && !opera) {
for (i=0;i<=translayersmax;i++) {
document.write('<span ID="trans'+i+'"
style="position:absolute;top:0px;left:'+translayersleftpos+'px;width:'+
translayerswidth+'px;height:'+tableheight+'px;background-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='+translayersopacity+');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+'px;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;background-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*textborder) {
document.ticker.clip.left+=step;
}
document.ticker.clip.right+=step;
if(document.ticker.left<-textcontentwidth+document.marker.pageX) {
document.ticker.left=textwidth+document.marker.pageX-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=parseInt(document.getElementById('ticker').style.left)-step
if
(parseInt(document.getElementById('ticker').style.left)<-textcontentwidth)
{
document.getElementById('ticker').style.left=textwidth
}
}
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('tickersize').offsetWidth
document.getElementById('roof').style.left=DL_GetElementLeft(document.getElementById('marker'));
document.getElementById('roof').style.top=DL_GetElementTop(document.getElementById('marker'));
document.getElementById('ticker').style.left=textwidth
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>