Why is the scrolling function not working with Internet Explorer

Discussion in 'HTML' started by Stefan Mueller, Nov 14, 2005.

  1. I'd like to set the focus to a field which is quite at the bottom of my
    page. But I'd like that the page is shown at the top. If you press a key the
    page should scroll down to the field.
    In Mozilla and Opera the following code works fine. But why isn't it working
    with the Internet Explorer?

    Stefan

    PS: If I don't set the focus to the filed I can scroll with
    window.scrollTo(0, 20);
    to every place where I'd like to also with the Internet Explorer.

    ========================================

    <html>
    <script type = 'text/javascript'>
    function AfterLoad() {
    document.MyForm.MyField.focus();
    window.scrollTo(0, 0); // Supposed to be scrolling to the top of
    the page
    }
    </script>

    <body onLoad = "AfterLoad()">
    <form name="MyForm">
    Top Row
    <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
    <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
    <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
    <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
    <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
    <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
    <input type = "input" name = "MyField" value = "">
    </form>
    </body>
    </html>
     
    Stefan Mueller, Nov 14, 2005
    #1
    1. Advertising

  2. Stefan Mueller

    BootNic Guest


    > "Stefan Mueller" <> wrote:
    > news:dl8q7f$jqb$-plus.net....
    >
    > <script type = 'text/javascript'>
    > function AfterLoad() {
    > document.MyForm.MyField.focus();
    > window.scrollTo(0, 0); // Supposed to be scrolling to the
    > top of the page
    > }
    > </script>


    <script type='text/javascript'>
    function AfterLoad() {
    document.MyForm.MyField.focus();
    setTimeout('window.scrollTo(0, 0)',1);
    }
    </script>

    --
    BootNic Monday, November 14, 2005 2:30 AM

    Humor is just another defense against the universe.
    *Mel Brooks*
     
    BootNic, Nov 14, 2005
    #2
    1. Advertising

  3. > <script type='text/javascript'>
    > function AfterLoad() {
    > document.MyForm.MyField.focus();
    > setTimeout('window.scrollTo(0, 0)',1);
    > }
    > </script>


    Great, this works perfect.

    Many thanks
    Stefan

    PS: Do you think it's a bug or only a timing problem?
     
    Stefan Mueller, Nov 14, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. cmay
    Replies:
    0
    Views:
    1,154
  2. Mr. SweatyFinger
    Replies:
    2
    Views:
    2,078
    Smokey Grindel
    Dec 2, 2006
  3. Ed Hauptman
    Replies:
    7
    Views:
    1,049
    Ed Hauptman
    Aug 7, 2009
  4. John Smith
    Replies:
    1
    Views:
    157
    Evertjan.
    Mar 12, 2005
  5. Stefan Mueller
    Replies:
    0
    Views:
    129
    Stefan Mueller
    Nov 14, 2005
Loading...

Share This Page