focus() does not behave as expected

Discussion in 'Javascript' started by Ben Dong, Jul 8, 2003.

  1. Ben Dong

    Ben Dong Guest

    Can someone help me understand why the focus() method in the following code
    snippet does not do what is expected; which is to reposition the cursor back
    to the same element after the alert() message has been displayed:

    <head>
    ....
    <script>
    function checkABC(element) {
    alert("Hey, you changed me to " + element.value + "!!");
    element.focus();
    return true;
    }
    </script>
    ....
    </head>
    ....
    ....
    ....
    <form>
    <table>
    ....
    <tr>
    <td valign="middle" bgcolor="#DDCCDD">
    <input type="text" name="ABC" value="12345" size="5"
    onChange="checkABC(this);" /><br />
    ....
    </td>
    ....
    </tr>
    ....
    </table>
    </form>

    Thanks, Ben
    Ben Dong, Jul 8, 2003
    #1
    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. Michael
    Replies:
    4
    Views:
    14,417
    Michael
    Aug 4, 2005
  2. Replies:
    12
    Views:
    2,222
    Howard
    Jun 16, 2005
  3. Raymond Hettinger
    Replies:
    3
    Views:
    275
    Claudio Grondi
    Aug 26, 2005
  4. Replies:
    2
    Views:
    120
  5. Roger
    Replies:
    3
    Views:
    303
Loading...

Share This Page