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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Weird Image Scrolling Script...Please Help

Status
Not open for further replies.

SonicMax

Technical User
Sep 14, 2003
62
0
0
US
People,

Can someone please take a look at this scrolling graphic & tell me what’s wrong with the script?:


I had wanted to add a graphic of a sound wave to my new site (created in Dreamweaver MX...which will be a resource site for digital musicians when complete); & to have it scroll across the page to resemble an audio track during playback in a computer-based digital audio workstation.

I created the graphic myself; & thought I had it configured properly with an appropriate java script to scroll at just the right speed…but when I uploaded the site, the script caused it to scroll just fine…but the cursor on the page undergoes a rapid-fire toggling between the cursor arrow & the hourglass.

One java programmer tells me it’s because the cursor is switching between normal & busy…due to the fact that the code is making a server call at the same rate the script causes it to scroll.

Another told me the problem can be fixed if the coding sets up the graphic to cache.

Here's the script:

<script>
function moveBackground(x) {
var obj = document.getElementById('testy');
obj.style.backgroundPosition = ""+x+"px 0px";
setTimeout("moveBackground("+(x+1)+")",25);
}
</script>

<body onload="moveBackground(0);">

<div id="testy" style="background:url(graphic.jpg) repeat-x; height:XXpx; width:XXXpx;">&nbsp;</div>

The only thing I did (if you view my source code) was to add absolute positioning to the layer, so as to have it scroll across the page at the height & position I wanted.

Can somebody help me out, here?...I’m not a programmer…but this page is almost there…almost working.

Thanks very much,

Sonic Max
 

Try moving the styling to a style sheet... since it may be that IE is trying to test to see if it is the same background image every time you try to move it.

Code:
<style type="text/css">
#testy {
  background:url(graphic.jpg) repeat-x;
  height:XXpx;
  width:XXXpx;
}
</style>

You may also find the problem is with your IE settings (set to check for a new version of the page every time -- if so try setting to automatic).

It worked perfectly fine for me in Safari 1.3 on MacOSX.

You could look at another solution where you place the image in a div and move that div behind another div with overflow set to hidden. If you need to go down this route... let us know.

Jeff
 
Jeff...

Where would the new code go; & what would be removed?

Also...I went to Internet Options...but could not find "new page version" anywhere. Is that on the Advanced Tab?

Thanks,

Sonic Max
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top