Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 265115
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:44:31+00:00 2026-05-11T22:44:31+00:00

I’ve been searching the net hard for some javascript code that allows me to

  • 0

I’ve been searching the net hard for some javascript code that allows me to automatically scroll images non-stop horizontally on a webpage. After a long time searching, I finally came across something that was close enough. I then customised it as much as possible to make it do exactly what I wanted it to do.

This testing was done on a page without a DOCTYPE, so when I moved it over to a page that had a DOCTYPE, the javascript got messed up and refused to scroll. It just showed a single stationary image (on safari and firefox)

I’ve uploaded both webpages to my MobileMe site so you guys can have a look.

The page without a DOCTYPE: web.me.com/zubby

The page with a DOCTYPE: web.me.com/zubby/2.html

the javascript is also detailed below. I’ll be extremely thankful if someone can help me out with this.

I only uploaded the relevant files so firebug will probably complain about non-existent functions.

var pic = new Array();

function banner(name, width, link){
    this.name = name
    this.width = width
    this.link = link
   };

pic[0] = new banner('images/cellarpics/cellarbynightsmall.jpg',203,'images/cellarpics/cellarbynightsmall.jpg');
pic[1] = new banner('images/cellarpics/insidecellarnewsmall.jpg',203,'images/cellarpics/insidecellarnewsmall.jpg');
pic[2] = new banner('images/cellarpics/mainshotwebsmall.jpg',203,'images/cellarpics/mainshotwebsmall.jpg');
pic[3] = new banner('images/cellarpics/MicroCelllar2tileopensmall.jpg',203,'images/cellarpics/MicroCelllar2tileopensmall.jpg');
pic[4] = new banner('images/cellarpics/openmicrosmall.jpg',203,'images/cellarpics/openmicrosmall.jpg');
pic[5] = new banner('images/cellarpics/topopenweb1small.jpg',203,'images/cellarpics/topopenweb1small.jpg');
pic[6] = new banner('images/cellarpics/topweb2small.jpg',203,'images/cellarpics/topweb2small.jpg');
pic[7] = new banner('images/cellarpics/topwebclosed1small.jpg',203,'images/cellarpics/topwebclosed1small.jpg');
/*
pic[8] = new banner('http://www.sxc.hu/pic/s/d/da/da9l/290444_yellow_rose.jpg',102,'http://www.sxc.hu/pic/m/d/da/da9l/290444_yellow_rose.jpg')
*/

var speed = 10;

var kk = pic.length;
var ii;
var hhh;
var nnn;
var myInterval;
var myPause;
var mode = 0;


var imgArray = new Array(kk);
var myLeft = new Array(kk);

for (ii=0;ii<kk;ii++){
imgArray[ii] = new Image()
imgArray[ii].src = pic[ii].name
imgArray[ii].width = pic[ii].width

    hhh=0 
    for (nnn=0;nnn<ii;nnn++){
        hhh=hhh+pic[nnn].width
    };
    myLeft[ii] = hhh
};

function ready(){
    for (ii=0;ii<kk;ii++){ 
        if (document.images[ii].complete == false){
            return false    
            break
        };
    };
return true
};


function startScrolling(){
    if (ready() == true){       
        window.clearInterval(myPause)
        myInterval = setInterval("autoScroll()",speed)  
    };
};


function autoScroll(){
    for (ii=0;ii<kk;ii++){
        myLeft[ii] = myLeft[ii] - 1

    if (myLeft[ii] == -(pic[ii].width)){
        hhh = 0
        for (nnn=0;nnn<kk;nnn++){
            if (nnn!=ii){
                hhh = hhh + pic[nnn].width
            };      
        };
        myLeft[ii] =  hhh
    };


        document.images[ii].style.left = myLeft[ii]
    };
    mode = 1
};

function stop(){
    if (mode == 1){
        window.clearInterval(myInterval)
    };
    if (mode == 0){
        window.clearInterval(myPause)
    };  
};

function go(){
    if (mode == 1){
        myInterval = setInterval("autoScroll()",speed)
    };
    if (mode == 0){
        myPause = setInterval("startScrolling()",3000)
    };  
};

myPause = setInterval("startScrolling()",100)

for (ii=0;ii<kk;ii++){
document.write('<a href="' + pic[ii].link + '" target="_blank"><img style="height:131px;position:absolute;top:0;left:' + myLeft[ii]  + ';" src="' + pic[ii].name + '" onMouseOver="stop()" onMouseOut="go()" /></a>');
};
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T22:44:31+00:00Added an answer on May 11, 2026 at 10:44 pm

    In IE it works. The reason is that with doctype, setting css declaration left works differently, seems that only a number is not enough…to make it work, in this function autoscroll()

    Change

    document.images[ii].style.left = myLeft[ii]

    to

    document.images[ii].style.left = myLeft[ii] + "px"

    Also, two of your scripts don’t load, menu.js and js/prettyPhoto.js

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 208k
  • Answers 208k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Shouldn't s.ADD(12,34); textBox1.Text = s.ToString(); be textbox1.Text = s.ADD(12, 34).ToString();… May 12, 2026 at 9:30 pm
  • Editorial Team
    Editorial Team added an answer The REPLICATE function returns data in the same type as… May 12, 2026 at 9:30 pm
  • Editorial Team
    Editorial Team added an answer Yes, that is the correct behavior of HTMLFormElement.submit() The reason… May 12, 2026 at 9:30 pm

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a French site that I want to parse, but am running into
I have text I am displaying in SIlverlight that is coming from a CMS
I am currently running into a problem where an element is coming back from

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.