Forum Moderators: open
I'm new in this forum, I hope I can get to know everyone here........
I have a strange problem with JS news ticker. I got this free script and I want to put it on my web page. I download the script and give a try on Firefox and IE. It works ok on both browsers. Seeing that I wouldnt have any compatibility problems then I put the script into my page. What do you know? It doesnt work........ Firefox doesnt give any error/warning on its javascript console. When I run it, it only shows Testing Line 1, it doesnt scroll as it has to........(only on firefox)
Here's the code:
news.js
var swidth='100%'
var sheight='40'
var sspeed='2'
var singletext=new Array()
if (singletext.length>1)
i=1
else
i=0
function start(){
if (document.all){
ieslider1.style.top=sheight
iemarquee(ieslider1)
}
else if (document.layers){
document.ns4slider.document.ns4slider1.top=sheight
document.ns4slider.document.ns4slider1.visibility='show'
ns4marquee(document.ns4slider.document.ns4slider1)
}
else if (document.getElementById&&!document.all){
document.getElementById('ns6slider1').style.top=sheight
ns6marquee(document.getElementById('ns6slider1'))
}
i=1
}
function iemarquee(whichdiv){
iediv=eval(whichdiv)
if (iediv.style.pixelTop>0&&iediv.style.pixelTop<=sspeed){
iediv.style.pixelTop=0
setTimeout("iemarquee(iediv)",100)
}
if (iediv.style.pixelTop>=sheight*-1){
iediv.style.pixelTop-=sspeed
setTimeout("iemarquee(iediv)",100)
}
else{
iediv.style.pixelTop=sheight
iediv.innerHTML=singletext[i]
if (i==singletext.length-1)
i=0
else
i++
}
}
function ns4marquee(whichlayer){
ns4layer=eval(whichlayer)
if (ns4layer.top>0&&ns4layer.top<=sspeed){
ns4layer.top=0
setTimeout("ns4marquee(ns4layer)",100)
}
if (ns4layer.top>=sheight*-1){
ns4layer.top-=sspeed
setTimeout("ns4marquee(ns4layer)",100)
}
else{
ns4layer.top=sheight
ns4layer.document.write(singletext[i])
ns4layer.document.close()
if (i==singletext.length-1)
i=0
else
i++
}
}
function ns6marquee(whichdiv){
ns6div=eval(whichdiv)
if (parseInt(ns6div.style.top)>0&&parseInt(ns6div.style.top)<=sspeed){
ns6div.style.top=0
setTimeout("ns6marquee(ns6div)",100)
}
if (parseInt(ns6div.style.top)>=sheight*-1){
ns6div.style.top=parseInt(ns6div.style.top)-sspeed
setTimeout("ns6marquee(ns6div)",100)
}
else{
ns6div.style.top=sheight
ns6div.innerHTML=singletext[i]
if (i==singletext.length-1)
i=0
else
i++
}
}
my index.html:
<html>
<head>
<title>Welcome</title>
<script type="text/javascript" language="javascript">
singletext[0]='Testing line 1'
singletext[1]='Testing line 2'
singletext[2]='Testing line 3'
</script>
<script type="text/javascript" language="javascript" src="news.js"></script>
</head>
<body onLoad="start()">
<div id="body">
....................
<div id="news">
<span class="sectionheader">Announcements</span>
<div align="center">
<span style="borderWidth:1; borderColor:red; width:350; height:72; background:navy">
<ilayer id="ns4slider" width="&{swidth};" height="&{sheight};">
<layer id="ns4slider1" height="&{sheight};" onmouseover="sspeed=0;" onmouseout="sspeed=2">
<script language="JavaScript">
if (document.layers)
document.write(singletext[0])
</script>
</layer></ilayer>
<script language="JavaScript">
if (document.all){
document.writeln('<div style="position:relative;overflow:hidden;width:'+swidth+';height:'+sheight+';clip:rect(0 '+swidth+' '+sheight+' 0);border:1 solid red;" onmouseover="sspeed=0;" onmouseout="sspeed=2">')
document.writeln('<div id="ieslider1" style="position:relative;width:'+swidth+';">')
document.write(singletext[0])
document.writeln('</div></div>')
}
if(document.getElementById&&!document.all){
document.writeln('<div style="position:relative;overflow:hidden;width:'+swidth+';height:'+sheight+';clip:rect(0 '+swidth+' '+sheight+' 0);border:1px solid red;" onmouseover="sspeed=0;" onmouseout="sspeed=2">')
document.writeln('<div id="ns6slider1" style="position:relative;width:'+swidth+';">')
document.write(singletext[0])
document.writeln('</div></div>')
}
</script></span>
</div>
<span class="more_announcements"><a href="news.html">more announcements</a></span>
</div>
...................................
</div>
</body>
</html>
Thanks
Kapalselam
Thank you for replying for this topic. I have changed that part, if i remove &&!document.all IE will printout the animated scroller plus one extra static line. I changed to else IE works fine. But still, these two approaches dont change anything with FIREFOX. I even tried to put that part into a table probably the parent div causes the script to stand still, it didnt work either.......... Strange thing is, when I previewed on Firefox from [javascript.internet.com...]
It works fine.... Seems that when I try to embed it to my html page, it wont work.... I really have no idea at all.... any other suggestions?
Thanks
KapalSelam