I am trying to get my HTML auto scroll to start upon opening..

Discussion in 'HTML & Website Design' started by broken art, Dec 19, 2012.

  1. #1
    I am trying to get my HTML auto scroll to start upon opening.. It is a script that was posted to this site and it works pretty well, with one issue... The user has to "nudge" the scroll to start the auto scroll... How can I alter the script to make it "automatically" start? I would appreciate the assist... :)
    The script is a follows...
    ----<SCRIPT language=JavaScript1.2>
    //change 1 to another integer to alter the scroll speed. Greater is faster
    var speed=1
    var currentpos=0,alt=1,curpos1=0,curpos2=-1
    function initialize(){
    startit()
    }
    function scrollwindow(){
    if (document.all &&
    !document.getElementById)
    temp=document.body.scrollTop
    else
    temp=window.pageYOffset
    if (alt==0)
    alt=2
    else
    alt=1
    if (alt==0)
    curpos1=temp
    else
    curpos2=temp
    if (curpos1!=curpos2){
    if (document.all)
    currentpos=document.body.scrollTop+speed
    else
    currentpos=window.pageYOffset+speed
    window.scroll(0,currentpos)
    }
    else{
    currentpos=0
    window.scroll(0,currentpos)
    }
    }
    function startit(){
    setInterval("scrollwindow()",400)
    }
    window.onload=initialize
    </SCRIPT>

    ---------
    Thanks!!!
     
    broken art, Dec 19, 2012 IP
  2. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #2
    1) you might have better luck asking this in the javascript forum.

    2) that script seems pretty outdated '90's style.

    3) what do you mean 'nudge' to start? It's trapping onload...

    4) do you have a link to the site in question so we can see what it is you're even trying to do?!? (I suspect we're talking one of those bandwidth wasting inaccessible "gee ain't it neat" all one page sites... but that's a wild guess)

    5) Most importantly -- if you need javascript to 'scroll' to part of your page, there is something horrifically WRONG with your layout... to the point that throwing more code at it is probably not the answer.
     
    deathshadow, Dec 20, 2012 IP