Javascript - I hate it - jump to end of page

Discussion in 'HTML & Website Design' started by AstarothSolutions, Oct 25, 2007.

  1. #1
    To cut to the chase...

    I have a long page at the bottom of which is a form, textbox and a button. When the page loads I want the full form to be shown and the textbox to be the focus.

    Whilst I can do both of these separately I cannot do the two together. My method of jumping to the end of the page has been to add an anchor link and using location.hash='anchorname" which when the page loads the url in the page top then changes to mypage.html#anchorname and the focus is then lost.

    Any ideas how to do the two together? The only added complication is the fact that the textbox name changes each time the page refreshesh (somewhat intentionally) and so the focus is done on an onload called in the textbox itself
     
    AstarothSolutions, Oct 25, 2007 IP
  2. AstarothSolutions

    AstarothSolutions Peon

    Messages:
    2,680
    Likes Received:
    77
    Best Answers:
    0
    Trophy Points:
    0
    #2
    finally found a working solutions with

    
    function scrollToBottom(){
    var scrollH=document.body.scrollHeight;
    var offsetH=document.body.offsetHeight;
    if(scrollH>offsetH) window.scrollTo(0,scrollH);
    else window.scrollTo(0,offsetH);
    }
    
    Code (JavaScript):
     
    AstarothSolutions, Oct 25, 2007 IP