[Javascript] Scrolling image on header

Scott Hamm ScottHam at clientlogic.com
Wed Aug 18 07:41:35 CDT 2004


Using the existing code in my html:

<div id=layer0 style="background:url('toptest_files/scroller.jpg')
repeat-x;"></div>
<script language="JavaScript"  type="text/javascript"
src="CSSHScroller.js"></script>

And in CSSHScroller.js:

function rollBackground(id, x, y, t)
{
  obj = document.getElementById(id)
  if (obj.style)
  { bgPos = obj.style.backgroundPosition.split(' ');
    X     = parseInt(bgPos[0]);
    Y     = parseInt(bgPos[1]);
    obj.style.backgroundPosition = (X+x)+"px "+(Y+y)+"px";
  }

  setTimeout("rollBackground('"+id+"', "+x+", "+y+", "+t+")", t);
}
rollBackground('layer0',-5,0,50)


I've been trying to figure out a way to change javascript to run scrolling
image on h1, h2, h3 and so on like so:

<h5style="background:url('toptest_files/scroller.jpg') repeat-x;">Text</h5>
<script language="JavaScript"  type="text/javascript"
src="CSSHScroller.js"></script>

Or if anyone have better idea, I would love to hear them! If possible use
only this in html:


<head>
<script language="JavaScript"  type="text/javascript"
src="CSSHScroller.js"></script>
<style>
<!--
h5 {background:url('toptest_files/scroller.jpg') repeat-x;}
-->
</style>
</head>
<body>
<h5>Some Text</h5>
</body>

Would be appreciated! :)





More information about the Javascript mailing list