Actually, I had looked at the script before but, for a different reason. The person posting wanted to put spaces between the each section of content in the scroller. I suppose you know you can use the named entity non-breaking space:to add spaces to the content. This will be required to tweak the script once you apply the code updates I am going to offer in order to get it to pause. First of all this script has a statement:
Code:
marqueespeed=(document.all)? marqueespeed : Math.max(1, marqueespeed-1) //slow speed down by 1 for NS
Which although I understand the reasoning behind it, makes no sense to me as, in testing, both NS7.2 and NS4.79 showed no need for this, it just made them one step slower. Remove it and they all go the same speed. Remove it. Now things get a little tricky. Replace this function:
Code:
function scrollmarquee(){
if (iedom){
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed+"px"
else
cross_marquee.style.left=parseInt(marqueewidth)+8+"px"
}
else if (document.layers){
if (ns_marquee.left>(actualwidth*(-1)+8))
ns_marquee.left-=copyspeed
else
ns_marquee.left=parseInt(marqueewidth)+8
}
}
with these two functions and one call:
Code:
function scrollmarquee(){
if (iedom){
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed+"px"
else{
clearTimeout(t1);
clearTimeout(t2);
clearTimeout(t3);
cross_marquee.style.left=parseInt(marqueewidth)+8+"px"
p=40
strstp();
}
}
else if (document.layers){
if (ns_marquee.left>(actualwidth*(-1)+8))
ns_marquee.left-=copyspeed
else{
clearTimeout(t1);
clearTimeout(t2);
clearTimeout(t3);
ns_marquee.left=parseInt(marqueewidth)+8
p=40
strstp();
}
}
}
function strstp(){
t1=setTimeout("copyspeed=pausespeed",3050-p);
p=0
t2=setTimeout("copyspeed=marqueespeed",6100);
t3=setTimeout("strstp()",6200);
}
strstp()
Add this:just below:
Code:
////NO NEED TO EDIT BELOW THIS LINE////////////
Those modifications work well with the demo at speed 2, it looks even better if you add spaces to the content of the demo so that it looks like this:
Code:
var marqueecontent='<nobr><font face="Arial"> Thank you for visiting <a href="http://www.dynamicdrive.com">Dynamic Drive.</a> If you find this script useful, please consider linking to us by <a href="../link.htm">click here.</a> Enjoy your stay!</font></nobr>'
this is just to give you an idea of what is possible.
Now to explain how you can make use of these modifications to have your content display as you want it to:
Code:
t1=setTimeout("copyspeed=pausespeed",3050-p);
The 3050 in the above line is the number of milliseconds until the first pause.
Code:
t2=setTimeout("copyspeed=marqueespeed",6100);
6100 above is how long until resume in milliseconds, a good rule of thumb is to make it double the initial timeout. To understand how long the pause will be in this case, subtract the 3050 from the 6100.
Code:
t3=setTimeout("strstp()",6200);
this last timeout starts things over and should be just a tad longer than the resume value.
That is just about it. You will see a fudge value of p=40 which appears twice in the scrollmarquee function. For some reason this is needed to synchronize subsequent iterations with the initial one. The higher your speed the smaller this will have to be and it can vary if your initial pause timeout value varies, adjust this last to get things to line up in subsequent run throughs once the initial run through is to your satisfaction. Do not adjust the two p=0 statements. You can, as I hinted earlier, use the character to alter the spacing so things line up in a pleasing fashion. Enjoy!
Bookmarks