/    Sign up×
Community /Pin to ProfileBookmark

Scrolling Image Problems

Question:
[B]What needs to be changed to make the images scroll in a continuous loop with no space between the first and last image.[/B]

[SIZE=2]to view example:[/SIZE]

[URL=http://www.standupjetski.com/jeffindex.htm]http://www.standupjetski.com/jeffindex.htm[/URL]

The code I placed in the head is

[code=html]<title>Image Scroller</title>
<script type=”text/javascript”>
var imageURLs = new Array(); //array to store the image urls
/* * PUT YOUR IMAGES HERE * */
imageURLs[0]=”jeffbanshee.jpg”;
imageURLs[1]=”jeffoctane.jpg”;
imageURLs[2]=”jefffusion.jpg”;
imageURLs[3]=”jefftrx450r.jpg”;
imageURLs[4]=”jeffcrf450x.jpg”;
imageURLs[5]=”jeffsuperjet.jpg”;
imageURLs[6]=”jefff7.jpg”;
imageURLs[7]=”jeff650.jpg”;
imageURLs[8]=”jeffrxp.jpg”;
imageURLs[9]=”jeff3d.jpg”;
imageURLs[10]=”jeffsxr.jpg”;
imageURLs[11]=”jeffyzf450f.jpg”;

var delay = 50; //tume in ms between change of position
var move = 2; //how far does it move at once
var imheight=50;
function init() {
var imgstr=””;
for(var i=0; i<imageURLs.length; i++) {
imgstr+=(“<td><img id=’scrim”+i+”‘ src='”+imageURLs[i]+”‘ height='”+imheight+”px’/></td>”);
}
document.write(“<div id=’imov’ style=’position:absolute;top:0′><table><tr>”
+imgstr
+”</tr></table></div>”);
}

function scroll() {
var imd = document.getElementById(“imov”);
if(imd.style.right.substring(0, imd.style.right.indexOf(‘p’))<=(-imd.offsetWidth)) {
imd.style.right=(screen.width-20)+”px”;
}
imd.style.right=(imd.style.right.substring(0, imd.style.right.indexOf(‘p’))-move)+”px”;
setTimeout(“scroll()”, delay);
}
init();
</script>[/code]

Thanks in advance for any help.

Andrew

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@CrazyMerlinJan 20.2006 — try changing:

'i<imageURLs.length' to 'i<imageURLs.length+1'

then inside the for loop put:

if(i == imageURLs.length+1) i = 0;

break;

give that a go and let me know what happens
×

Success!

Help @standupjetski spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.15,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...