...

View Full Version : scrolling marquee



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




<html>
<head><title>test</title>
<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:'
+tWidth
+';height:'
+tHeight+';overflow:hidden;background-color:'
+tcolour+'"';
if (moStop) tick += ' onmouseover="cps=0" onmouseout="cps=tSpeed"';
tick +='><div id="mq" style="position:absolute;left:0px;top:0px;font-family:'
+fontfamily+';font-size:'
+fsz+'px;white-space:nowrap;"><\/div><div id="mq2" style="position:absolute;left:0px;top:0px;font-family:'
+fontfamily+';font-size:'
+fsz+'px;white-space:nowrap;"><\/div><\/div>';
document.getElementById('ticker').innerHTML = tick;
mq = document.getElementById("mq");
mq2 = document.getElementById("mq2");
//mq.style.left=(parseInt(tWidth)+10)+"px";
mq2.style.left = (parseInt(tWidth)+10)+"px";
mq.style.left="0px";
mq.innerHTML='<span id="tx">'
+content
+'<\/span>';
mq2.innerHTML='<span id="tx2">'
+content
+'<\/span>';
aw = document.getElementById("tx").offsetWidth;
pause = setTimeout('lefttime=setInterval("scrollticker()",50)', 1200);
//lefttime=setInterval("scrollticker()",1);
}
}

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";
}




window.onload=startticker;
</script>
</head>
<body style="background: #000000">
<div align="center">
<div id="ticker">
</div>
</div>
</body>
</html>



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?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum