Jump to content

  • Log in with Facebook Log in with Twitter Log In with Google      Sign In   
  • Create Account

Subscribe to HRA Now!

 



SEO Class in Chicago, IL

Learn How To Optimize Your Website on July 26, 2013


Looking for personalized in-depth SEO training among your peers?



High Rankings is offering a 1-day customized SEO training class in Chicago. Class size is limited so please sign-up now if you want in!



 


Are you a Google Analytics enthusiast?

Share and download Custom Google Analytics Reports, dashboards and advanced segments--for FREE! 

 



 

 www.CustomReportSharing.com 

From the folks who brought you High Rankings!



Photo
- - - - -

Need A Vertical Image Scroller


  • Please log in to reply
22 replies to this topic

#1 lyn

lyn

    HR 6

  • Active Members
  • PipPipPipPipPipPip
  • 940 posts
  • Location:London, Ontario

Posted 14 December 2005 - 01:52 PM

I have a scripting challenge for anyone who's inclined that way...
I'm working on a site that displays an array of images - logos, actually - stacked up along the left side of the page. Could go to 25 or more images in the array.

I'd like a script that rotates the images around on a timer so, every couple seconds, the top image moves to the bottom and all the others move up a space. All the images need to have individual links.

I've seen lots of vertical scrollers but they all have problems so far:
1) only show 1 image at a time - I need all images displayed at once
2) scroll continuously - would much prefer to have each image pause before scrolling
3) java applet - would prefer to use a code that's not so likely to be blocked by the browser
4) High maintenance - we'll have a new set of images every month and don;t want to have to rebuild a complete animation file every time
5) broken in Firefox - have a javascript now that works fine in IE but disappears in Firefox 1.0

Ideally, for simplicity I suppose, this would be a DHTML script.

Any hints welcome! goodjob.gif

L.

#2 qwerty

qwerty

    HR 10

  • Moderator
  • 8,296 posts
  • Location:Somerville, MA

Posted 14 December 2005 - 02:03 PM

I've used one that scrolls constantly, but apart from that it does what you want. If I remember correctly, its default function was to run vertically, and I edited it to be horizontal. You can see it at http://www.psipay.com/ (scroll down a bit). There's some text followed by a bunch of logos.

The original script is at http://www.dynamicdr...me-scroller.htm if you want to use it.

#3 lyn

lyn

    HR 6

  • Active Members
  • PipPipPipPipPipPip
  • 940 posts
  • Location:London, Ontario

Posted 14 December 2005 - 03:42 PM

Thanks Bob
These are pretty close - they are similar to another I found earlier this morning.
Where I get problem is at the end of scrolling items, where the window goes blank before it restarts. In my application, we'll have a huge long window going blank, then and remains blank at the top of the page until the first image is able to scroll the full length.

To work properly, this thing really needs to be on some kind of loop - every item is visible all the time, and the window is full all the time.

Too much?

L.

#4 qwerty

qwerty

    HR 10

  • Moderator
  • 8,296 posts
  • Location:Somerville, MA

Posted 14 December 2005 - 03:48 PM

If you look at the code behind mine, it's a matter of setting the proper width of the iframe. It took me about ten tries to get it right, and then the client added some new logos and screwed it up, so I was back to where I started. But if you can get the iframe to be exactly as wide as the content in it, you'll have a loop with no blank area.

I bet somebody in here could write a script that would dynamically loop through the images, add their widths to whatever padding you want, and set that as the width of the iframe.

#5 lyn

lyn

    HR 6

  • Active Members
  • PipPipPipPipPipPip
  • 940 posts
  • Location:London, Ontario

Posted 15 December 2005 - 07:19 AM

Thanks again - I'll go back to that original (vertical) script and see if I can get a box height that works as yours did.

Plan B, I think, would be to find us a codehead to hack the script we already have into something that Firefox can run.

We're hoping to have this site switched over to a CMS early in the new year, so it would help to have something that adapts to the number and size of logos we have to show each month.

L.

#6 Raphael

Raphael

    The Limey Cowboy

  • Active Members
  • PipPipPipPipPipPip
  • 722 posts
  • Location:New England

Posted 15 December 2005 - 07:29 AM

lyn, does it actually have to *scroll* or can you simply have the images in predefined spots and move them up one at a time, wrapping when they get to the top?

Does that make sense?

With the pause that you're talking about it seems much less of a scroller than a rotational swapper.

#7 Raphael

Raphael

    The Limey Cowboy

  • Active Members
  • PipPipPipPipPipPip
  • 722 posts
  • Location:New England

Posted 15 December 2005 - 07:50 AM

oh yeah, and are all your images the same size/height?

#8 lyn

lyn

    HR 6

  • Active Members
  • PipPipPipPipPipPip
  • 940 posts
  • Location:London, Ontario

Posted 15 December 2005 - 08:00 AM

"Rotational swapper" is a phrase I've been hankering for, for weeks now. Thanks so much -- it's EXACTLY what I need! That's what our current script does now (just not in FF!)

And, the logos we have at this point are not all the same size, but it's in our control to make them fit a prescribed height.

Think there might be something out there?

L.

#9 Raphael

Raphael

    The Limey Cowboy

  • Active Members
  • PipPipPipPipPipPip
  • 722 posts
  • Location:New England

Posted 15 December 2005 - 08:11 AM

QUOTE(lyn @ Dec 15 2005, 09:00 AM)
"Rotational swapper" is a phrase I've been hankering for, for weeks now. Thanks so much -- it's EXACTLY what I need! That's what our current script does now (just not in FF!)

And, the logos we have at this point are not all the same size, but it's in our control to make them fit a prescribed height.

Think there might be something out there?

L.
View Post

Gimme 30 minutes....

#10 Raphael

Raphael

    The Limey Cowboy

  • Active Members
  • PipPipPipPipPipPip
  • 722 posts
  • Location:New England

Posted 15 December 2005 - 08:46 AM

Okay, this is not at all optimized, nor is it pretty. But it works. Or at least, it seems to work here at home:

CODE
<html>
<head>
</head>
<body onLoad="initScroll();">
<div id="imagediv" style="position:absolute;top:10;left:100;">
<p><a id="img0link" target="_new" href="link1.html"><img id="img0" src="img1.jpg" style="border:0px;" /></a><p />
<p><a id="img1link" target="_new" href="link2.html"><img id="img1" src="img2.jpg" style="border:0px;" /></a><p />
<p><a id="img2link" target="_new" href="link3.html"><img id="img2" src="img3.jpg" style="border:0px;" /></a><p />
<p><a id="img3link" target="_new" href="link4.html"><img id="img3" src="img4.jpg" style="border:0px;" /></a><p />
<p><a id="img4link" target="_new" href="link5.html"><img id="img4" src="img5.jpg" style="border:0px;" /></a><p />
</div>
<script language = "javascript">

var numOfImages = 5;
var initialDelay = 2000; // this is in milliseconds;
var delayBetweenSwap = 2000; // So is this;
var globalCount = 1;

// Initialize these with the total number of images
var imgArray = new Array(5);
var linkArray = new Array(5);

// Fill this arrasy with the image srcs themselves
imgArray[0] = "img1.jpg";
imgArray[1] = "img2.jpg";
imgArray[2] = "img3.jpg";
imgArray[3] = "img4.jpg";
imgArray[4] = "img5.jpg";

// fill this array with the href targets that you want the images to link to
linkArray[0] = "link1.html";
linkArray[1] = "link2.html";
linkArray[2] = "link3.html";
linkArray[3] = "link4.html";
linkArray[4] = "link5.html";

function initScroll() {
    /*
 Function just initializes the swap routine
    */
    
    var initialRun = setTimeout("doSwap()",initialDelay);
}

function doSwap() {
    /*
 This is the meat of the swapping routine
    */

    /*
 First things first, iterate through our images
 and change their source and their href
    */
    for (var i=0;i<numOfImages;i++) {
 var element = document.getElementById("img"+i);
 var link = document.getElementById("img"+i+"link");
 
 /*
     Have to make sure we wrap around after we reach the max number of images
 */
 var nextImg = i + globalCount;
 if (nextImg >=numOfImages) {
     nextImg = nextImg-numOfImages;
     
 }

 /*
     Swap images and hrefs
 */
 var newImgSrc = imgArray[nextImg];
 var newImgLink = linkArray[nextImg];
 element.src = newImgSrc;
 link.href = newImgLink;
 
 
    }
    if (globalCount > numOfImages) {
 globalCount = 0;
    }
    globalCount++;
    setTimeout("doSwap()",delayBetweenSwap);
    
}

</script>
</body>
</html>


Cut and paste that into an HTML file, make yourself five images called img1.jpg, img2.jpg,img3.jpg, img4.jpg and img5.jpg, put them in the same folder as the html file and test it out.

This isn't a scroller, it's a rotational swapper. It just swaps the image above with the one below, running all the way down the list. Let me know if you have any problems with it

#11 Raphael

Raphael

    The Limey Cowboy

  • Active Members
  • PipPipPipPipPipPip
  • 722 posts
  • Location:New England

Posted 15 December 2005 - 08:48 AM

Well, goddamn, I just noticed. I posted my "Gimme 30 minutes at 9:11, forum time", posted my code at 9:46.. Almost exactly 30 minutes later. Not bad, eh?

#12 qwerty

qwerty

    HR 10

  • Moderator
  • 8,296 posts
  • Location:Somerville, MA

Posted 15 December 2005 - 09:32 AM

What service! appl.gif

#13 Jill

Jill

    High Rankings Advisor

  • Admin
  • 32,326 posts

Posted 15 December 2005 - 10:07 AM

Raph, you can take a break from shoveling my driveway today because of all your hard work here! wink.gif

#14 dmcconkey

dmcconkey

    HR 4

  • Active Members
  • PipPipPipPip
  • 150 posts
  • Location:Charlotte, NC, USA

Posted 15 December 2005 - 10:17 AM

So becomming a mod grants you super-human JS powers? Good show.

#15 lyn

lyn

    HR 6

  • Active Members
  • PipPipPipPipPipPip
  • 940 posts
  • Location:London, Ontario

Posted 15 December 2005 - 12:14 PM

Outstanding, Raph!
I'll go give it a run right now.
Thanks, thanks, thanks for the time & effort.
QUOTE
Almost exactly 30 minutes later. Not bad, eh?

Waaay, not bad. goodjob.gif




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users