Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

rotating banner scolling rate

Status
Not open for further replies.

altaratz

ISP
Apr 15, 2001
73
US
I pulled the following code from a guy's dHTML site for a rotating banner. Everything about it works great, except that I can't figure out how to manage the scrolling rate.

Here's the part in the <HEAD> section:

<script language="JavaScript1.2">

/*
Horizontal Pausing News Scroller
Copyright David Miles (To add more shock to your site, visit Shock.com
*/
<!--

var scrollerwidth=300
var scrollerheight=180
var pausebetweenimages=3000

var hSlideContent=new Array()

hSlideContent[0]='<p>Horizontal Scrolling Layers</p><p>By David Miles<br><a href=" target="_blank"> this is snazzy.</p>'
hSlideContent[1]='<p>It sure is a good thing you decided to add more shock to your site, by visiting <a href=" target="_blank">DHTMLShock.com</a>. We have the highest quality DHTML and JavaScripts around.</p><p>(Please pardon our advertising propaganda.)</p>'
hSlideContent[2]='<p>3. Lorem ipsum dolor sit amet, consectetur adipscing elit, sed diam nonnumy eiusmod tempor incidunt ut labore et dolore magna aliquam erat volupat.</p><p>Et harumd dereud facilis est er expedit distinct. Nam liber a tempor cum soluta nobis eligend optio comque nihil quod a impedit anim id quod maxim placeat facer possim omnis es voluptas assumenda est, omnis dolor repellend. Temporem autem quinsud et aur office debit aut tum rerum necesit atib saepe eveniet ut er repudiand sint et molestia non este recusand.</p>'
hSlideContent[3]='4. still more text ...'

if (hSlideContent.length>1)
i=2
else
i=0

function locateObject(n, d) { //v3.0
var p,i,x;
if(!d) d=document;
if((p=n.indexOf("?"))>0&&parent.frames.length)
{
d=parent.frames[n.substring(p+1)].document;
n=n.substring(0,p);
}
if(!(x=d[n])&&d.all) x=d.all[n];

for (i=0;!x&&i<d.forms.length;i++) x=d.forms[n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=locateObject(n,d.layers.document);
return x;
}

function moveHTextFirstBlock(whichdiv)
{
if (document.all)
{
tdiv=eval(whichdiv)
if (tdiv.style.pixelLeft>0&&tdiv.style.pixelLeft<=5)
{
tdiv.style.pixelLeft=0
setTimeout("moveHTextFirstBlock(tdiv)",pausebetweenimages)
setTimeout("moveHTextSecondBlock('hTextSecond')",pausebetweenimages)
return
}
if (tdiv.style.pixelLeft>=tdiv.offsetWidth*-1)
{
tdiv.style.pixelLeft-=5
setTimeout("moveHTextFirstBlock(tdiv)",10)
}
else
{
tdiv.style.pixelLeft=scrollerwidth+5
tdiv.innerHTML=hSlideContent

if (i==hSlideContent.length-1)
i=0
else
i++
}
}
else
{
tlayer=eval(whichdiv)
if (tlayer.left>0&&tlayer.left<=5)
{
tlayer.left=0
setTimeout("moveHTextFirstBlock(tlayer)",pausebetweenimages)
setTimeout("moveHTextSecondBlock(locateObject('hTextSecond'))",pausebetweenimages)
return
}
if (tlayer.left>=tlayer.document.width*-1)
{
tlayer.left-=5
setTimeout("moveHTextFirstBlock(tlayer)",10)
}
else
{
tlayer.left=scrollerwidth+5
tlayer.document.write(hSlideContent)
tlayer.document.close()
if (i==hSlideContent.length-1)
i=0
else
i++
}
}
}

function moveHTextSecondBlock(whichdiv)
{
if (document.all)
{
tdiv2=eval(whichdiv)

if (tdiv2.style.pixelLeft>0&&tdiv2.style.pixelLeft<=5)
{
tdiv2.style.pixelLeft=0
setTimeout("moveHTextSecondBlock(tdiv2)",pausebetweenimages)
setTimeout("moveHTextFirstBlock('hTextFirst')",pausebetweenimages)
return
}
if (tdiv2.style.pixelLeft>=tdiv2.offsetWidth*-1){
tdiv2.style.pixelLeft-=5
setTimeout("moveHTextSecondBlock('hTextSecond')",10)
}
else
{
tdiv2.style.pixelLeft=scrollerwidth+5
tdiv2.innerHTML=hSlideContent
if (i==hSlideContent.length-1)
i=0
else
i++
}
}
else if (document.layers)
{
tlayer2=eval(whichdiv)

if (tlayer2.left>0&&tlayer2.left<=5)
{
tlayer2.left=0
setTimeout("moveHTextSecondBlock(tlayer2)",pausebetweenimages)
setTimeout("moveHTextFirstBlock(locateObject('hTextMain').document.layers['hTextFirst'])",pausebetweenimages)
return
}
if (tlayer2.left>=tlayer2.document.width*-1)
{
tlayer2.left-=5
setTimeout("moveHTextSecondBlock(tlayer2)",10)
}
else
{
tlayer2.left=scrollerwidth+5
tlayer2.document.write(hSlideContent)
tlayer2.document.close()
if (i==hSlideContent.length-1)
i=0
else
i++
}
}
}

function startHScroll(){
if (document.all)
{
locateObject('hTextSecond').style.left=scrollerwidth+5
locateObject('hTextSecond').visibility='visible'
moveHTextFirstBlock(locateObject("hTextFirst"))
}
else if (document.layers)
{
locateObject('hTextMain').visibility='show'
locateObject('hTextFirst').visibility='show'
locateObject('hTextSecond').left=scrollerwidth+5
locateObject('hTextSecond').visibility='show'
moveHTextFirstBlock(locateObject('hTextMain').document.layers['hTextFirst'])
}
}
//-->
</script>

----------------------------------------------------


then here's the part in the body section:

<div id="hTextMain" style="width:922; height:257; position:absolute; top: 319; left: 0; visibility: visible; clip: rect(0 922 257 0); overflow: hidden; z-index: 2">
<div id="hTextFirst" style="left:1; width:922;position:absolute; z-index: 1; padding: 0px 0px; visibility: visible; overflow: hidden; clip: rect(0 922 257 0)">
<script language="JavaScript">
document.write(hSlideContent[0])
</script>
</div>

<div id="hTextSecond" style="left:1; width:922;position:absolute; z-index: 0; padding: 0px 0px; visibility: visible; overflow: hidden; clip: rect(0 922 257 0)">
<script language="JavaScript">
document.write(hSlideContent[1])
</script>
</div>
</div>


Ya'll can goto to see the script in action - like I said, great, except that I want to slow the scrolling rate.

Thanks so much for any help . . .

-- Ethan
 
>var pausebetweenimages=3000
The smaller the faster?
 
no - that's not it, that's the pause time between images - I need to slow down the image scrolling rate itself
 
In that case, it would/might be this at numerous occurences:
[tt] setTimeout("moveHTextFirstBlock(tdiv)",10)[/tt]
Change the 10?
 
Though I may not be motivated to look into the script before advising, I may just point out how to know where to look for for this kind of moving/animating components-in case it might help you get the idea. It is usually executing routine under global context called upon via setTimeout() recurrently or setInterval(). That's how you look out for it.
- tsuji
 
thanks for your advice and time - I will try it out
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top