Why does Opera lose the focus on a input box if I scroll with a JavaScript

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

  1. With
    document.MyForm.MyField.focus();
    I set the focus to the input field just after the page has been loaded. This
    works perfect.
    Two seconds later the JavaScript
    window.setTimeout("window.scrollTo(0, 0)", 2000);
    scrolls to the top of the page.
    Unfortunately in Opera the input box loses the focus after the scrolling
    event. With Internet Explorer and Mozilla the focus is still on the input
    box.

    Is there a way (workaround) to keep the focus also with Opera on the input
    box?

    Stefan

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

    <html>
    <script type = 'text/javascript'>
    function AfterLoad() {
    document.MyForm.MyField.focus();
    window.setTimeout("window.scrollTo(0, 0)", 2000);
    }
    </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. Re: Why does Opera lose the focus on a input box if I scroll witha JavaScript

    Stefan Mueller wrote:
    > I set the focus to the input field just after the page has been loaded. This
    > works perfect.
    > Two seconds later the JavaScript
    > window.setTimeout("window.scrollTo(0, 0)", 2000);
    > scrolls to the top of the page.


    What reason could you possible have to do that other than to annoy your
    visitors?
     
    Leif K-Brooks, Nov 14, 2005
    #2
    1. Advertising

  3. Did you really not see the next sentence and the consequent question of my
    post?
    The posted code was just a simple example to show my problem.

    Stefan
     
    Stefan Mueller, Nov 15, 2005
    #3
  4. Stefan Mueller

    Spartanicus Guest

    "Stefan Mueller" <> wrote:

    >Did you really not see the next sentence and the consequent question of my
    >post?


    Who and what are you addressing? Quote a minimal bit of what you are
    replying to.

    >The posted code was just a simple example to show my problem.


    [browsing up the thread]

    Instead of multi posting a nonsensical question, you should have
    indicated in your first post that you didn't want to reveal what you are
    actually trying to do, that way we would not have wasted any time by
    replying to you.

    --
    Spartanicus
     
    Spartanicus, Nov 16, 2005
    #4
  5. > Who and what are you addressing? Quote a minimal bit of what you are
    > replying to.


    Sorry, but my provider doesn't allow me to quote more text than I write.
    It's a new setting on the news server. I've already complained about but
    they told me that this setting is quite common because so if you search a
    conversation on the internet you don't have to read the same text again and
    again.
    However, I just answered the post before.

    I'm just trying to find a solution so that Opera does not lose the focus on
    a input box if you scroll the page with a Javascript. With Internet Explorer
    and Mozilla the focus is still on the input box.

    Stefan
     
    Stefan Mueller, Nov 16, 2005
    #5
    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. Bob
    Replies:
    24
    Views:
    1,586
  2. Mr. SweatyFinger
    Replies:
    2
    Views:
    2,263
    Smokey Grindel
    Dec 2, 2006
  3. Gerardo ARnaez
    Replies:
    1
    Views:
    746
    Eric Brunel
    Aug 14, 2008
  4. Wai Man Chung

    Field lose focus after adding an applet object

    Wai Man Chung, Jul 8, 2003, in forum: ASP General
    Replies:
    1
    Views:
    145
    Luke Zhang [MSFT]
    Jul 10, 2003
  5. Replies:
    3
    Views:
    142
Loading...

Share This Page