...

View Full Version : Ticker Not Working



thesmart1
08-21-2007, 05:59 AM
I wrote a script for a ticker/marquee. The way it works is it moves a div left a bit each time the function is called (which continues forever with a setTimeout loop). However, it's not moving the div. I've been trying to debug it (you can see commented out variable definitions, which I then checked in FireBug for Firefox) for a while now, and I've figured out that everything is working the way it should, except for the line that actually sets the "marquee"'s "left" property.

Here's the script:

// ADJUST THESE VARIABLES HOWEVER YOU WANT

marqueeWidth='500px' // width of the marquee box
marqueeHeight='' // height of the marquee box. leave blank ('') to detect automatically.
marqueeContentWidth='1100px' // width of the content inside the marquee box. if the marquee is returning to the beginning before the content has scrolled out of view, increase this value.
marqueeBorderColor='#000000' // color of the border around the marquee box. must have '#' before hex code. leave blank ('') for no border
marqueeBgColor='#ff9900' // background color of the marquue box. must have '#' before hex code. leave blank ('') for transparent
marqueeSpeed=50 // time (in milliseconds) between calls to the function to move the marquee. the lower the number, the smoother the scroll, however, it may slow down the script.
marqueeIncrement=15 // number of pixels the marquee moves each time the function is called (use in conjunction with above var to acheive a smooth marquee at a desirable speed)


// DO NOT EDIT BELOW THIS LINE
//step=0;
function scrollMarquee(){
if (document.getElementById('marquee').offsetLeft>=(-1)*document.getElementById('marquee').offsetWidth){
document.getElementById('marquee').style.left=document.getElementById('marquee').offsetLeft-marqueeIncrement;
//gt=true;
}
else {
document.getElementById('marquee').style.left=marqueeWidth;
//gt=false;
}
setTimeout('scrollMarquee()',marqueeSpeed);
//step++;
//left=document.getElementById('marquee').offsetLeft;
//newleft=document.getElementById('marquee').offsetLeft-marqueeIncrement;
//marqueeleft=document.getElementById('marquee').offsetLeft;
//width=document.getElementById('marquee').offsetWidth;
//negwidth=(-1)*document.getElementById('marquee').offsetWidth;
}

function initMarquee(){
document.getElementById('marqueebox').style.width=marqueeWidth;
if (marqueeHeight!=''){
document.getElementById('marqueebox').style.height=marqueeHeight;
}
if (marqueeBorderColor!=''){
document.getElementById('marqueebox').style.borderWidth='1px';
document.getElementById('marqueebox').style.borderStyle='solid';
document.getElementById('marqueebox').style.borderColor=marqueeBorderColor;
}
if (marqueeBgColor!=''){
document.getElementById('marqueebox').style.backgroundColor=marqueeBgColor;
}
document.getElementById('marquee').style.position='relative';
document.getElementById('marquee').style.top='0px';
document.getElementById('marquee').style.left=marqueeWidth;
document.getElementById('marqueebox').style.overflow='hidden';
document.getElementById('marqueebox').style.whiteSpace='nowrap';
document.getElementById('marquee').style.width=marqueeContentWidth;
setTimeout('scrollMarquee()',marqueeSpeed);
}"marqueeInit()" is called in the body's onload event.

Any ideas on what's going on?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum