View Full Version : scrolling marquee

10-27-2006, 05:43 PM
I have the following code used to create a scrolling marquee:

<script type="text/javascript">
//scrolling marquee
var tWidth='595px'; // width (in pixels)
var tHeight='15px'; // height (in pixels)
var tcolour='#ffffff'; // background colour:
var moStop=false; // pause on mouseover (true or false)
var fontfamily = 'arial,sans-serif'; // font for content
var tSpeed=5; // scroll speed (1 = slow, 5 = fast)
var content='ajslkdfj hkjlashd ahsjfhasl dfjajsd ;fasidjf ahsdjfhajsd gjhaj jhjkahsdfg ajslkdfj hkjlashd ahsjfhasl dfjajsd ;fasidjf ahsdjfhajsd gjhaj jhjkahsdfg';
var cps=tSpeed;
var aw, mq, mq2;
var fsz = parseInt(tHeight)-4;

function startticker(){
if (document.getElementById) {
var tick = '<div style="position:relative;width:'
if (moStop) tick += ' onmouseover="cps=0" onmouseout="cps=tSpeed"';
tick +='><div id="mq" style="position:absolute;left:0px;top:0px;font-family:'
+fsz+'px;white-space:nowrap;"><\/div><div id="mq2" style="position:absolute;left:0px;top:0px;font-family:'
document.getElementById('ticker').innerHTML = tick;
mq = document.getElementById("mq");
mq2 = document.getElementById("mq2");
mq2.style.left = (parseInt(tWidth)+10)+"px";
mq.innerHTML='<span id="tx">'
mq2.innerHTML='<span id="tx2">'
aw = document.getElementById("tx").offsetWidth;
pause = setTimeout('lefttime=setInterval("scrollticker()",50)', 1200);

function scrollticker(){
mq.style.left = (parseInt(mq.style.left)>(-10 - aw)) /*|| (parseInt(mq2.style.left)>(-aw + 500))*/ ?parseInt(mq.style.left)-cps+"px" : parseInt(tWidth)+10+"px";//alert(aw + " " + parseInt(mq2.style.left));// parseInt(tWidth)+10+"px" //parseInt(tWidth)+10+"px";
mq2.style.left = (parseInt(mq.style.left)<(-aw + 500)) && (parseInt(mq.style.left)>(-10-aw)) ?parseInt(mq2.style.left)-cps+"px" : parseInt(tWidth)+10+"px" //parseInt(tWidth)+10+"px";

<body style="background: #000000">
<div align="center">
<div id="ticker">

Everything is working fine with this except now I would like to have the text continue to scroll instead of having a long blank space. I added the second mq to accomplish this. I scrolls correctly until about halfway through the second scroll it blanks out and starts over. I know I probably need something in the mq.style.left = and mq2.style.left = lines but just cant figure it out. Can anyone point me in the right direction?