109、文字向左滚动

109、文字向左滚动

脚本说明:

第一步:把如下代码加入<body>区域中

<script language="JavaScript1.2">

<!--

 

var scrollerwidth=300

var scrollerheight=180

var pausebetweenimages=5000

 

var hSlideContent=new Array()

 

hSlideContent[0]='<p>1.Horizontal Scrolling Layers</p><br><p>Damn, this is snazzy.</p>'

hSlideContent[1]='<p>2.It sure is a good thing you decided to add more shock to your site, by visiting <a href="http://www.7stk.com" 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[i][n];

  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=locateObject(n,d.layers[i].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[i]

 

       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[i])

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[i]

       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[i])

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>

<style type="text/css">

<!--

div {  font-family: Tahoma, Arial, Helvetica, sans-serif; font-size: 11px; color: #000000}

-->

</style>

 

<div id="hTextMain" style="width:300; height:180; position:absolute; top: 0; left: 0; visibility: visible; clip: rect(0 300 180 0); overflow: hidden; z-index: 2">

  <div id="hTextFirst" style="left:1; width:300;position:absolute; z-index: 1; padding: 1px 1px; visibility: visible; overflow: hidden; clip: rect(0 300 180 0)">

<script language="JavaScript">

document.write(hSlideContent[0])

</script>

</div> 

<div id="hTextSecond" style="left:1; width:300;position:absolute; z-index: 0; padding: 1px 1px; visibility: visible; overflow: hidden; clip: rect(0 300 180 0)">

<script language="JavaScript">

document.write(hSlideContent[1])

</script>

</div>

</div>

 

 

 

第二步:把<body>中的内容改为:

<body bgcolor="#fef4d9" onLoad="startHScroll()">

 

Write a comment

Comments: 0