Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Dec 2009
    Posts
    108
    Thanks
    22
    Thanked 2 Times in 2 Posts

    focus() method fails on FF?

    Hi,

    does 'focus' method show a 'stable' result? i call this method on a node -- if this one is not absolutely positioned -- it seems nothing happens
    so ① does this method only apply to absolutely positioned element?

    also, in FF, aNode.focus() has no effect whereas in IE document will scroll until that node is visible if the node is partially invisible at the bottom.
    ②is this a bug in FF?

    here is the code
    Code:
    <div style="position:absolute; left:50px; top: 700px" onclick="this.focus();">
    yepsfagadgre<br />agefderdsf<br />agefderdsf<br />agefderdsf</div>
    scroll the document until the text is half-visible at the bottom. click on it -- in IE it will scroll up while in FF nothing happens
    besides, if it is not absolutely positioned, nothing happens either~~~


    thx in advance

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,985
    Thanks
    203
    Thanked 2,536 Times in 2,514 Posts
    There is a bug in Firefox.

    You need to introduce small delay:-

    setTimeout("document.formname.fieldname.focus()", 25);
    or
    setTimeout("document.getElementById("fieldname").focus()", 25);

    if document.formname.fieldname or document.getElementById() is a variable, then that variable must be global.

    All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

  • Users who have thanked Philip M for this post:

    mehere8 (08-21-2010)

  • #3
    Regular Coder
    Join Date
    Dec 2009
    Posts
    108
    Thanks
    22
    Thanked 2 Times in 2 Posts
    thanks Philip
    i just wonder why there needs a delay for FF? any underlying mechanism?

    also, why non-absolutely positioned element cannot gain 'focus' (calling focus method yields no result)

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,985
    Thanks
    203
    Thanked 2,536 Times in 2,514 Posts
    Quote Originally Posted by mehere8 View Post
    i just wonder why there needs a delay for FF? any underlying mechanism?
    Because as I say there is a big in Firefox - focus() does not work unless there is a short delay.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •