Please Help! How to bring focus back on previous frame element

Discussion in 'Javascript' started by Dai Ba Wong, Jun 29, 2004.

  1. Dai Ba Wong

    Dai Ba Wong Guest

    Hi:

    Currently I am having a problem with my webpage. My page consist of
    two frames, one consist of input text field and the other contains
    link for different pop-up windows. The problem follows:

    1. At the beginning, focus is placed on an input text field of the
    first frame (so there's a blinking cursor on such field).

    2. Then users click on a link of the second frame (thus focus is set
    on the clicked link) and a second window popup.

    3. Right after users performed their operations on the pop-up window,
    they will close the window and will like to have focus brought back to
    the previously focused text field of the first field (Notice: After
    users close the pop-up window, the previously focused text input still
    have a blinking cursor and you may type on the field. However, if you
    tab out, you would fine that the focus is on the clicked link of the
    second frame. That means the focus is not on the first frame's text
    field and if such text field contains an onchange function, such
    function will not be activated as users tab out).

    My problem is as users click on the link of the second frame, the
    focus is placed on the selected link and a window pops up. How can I
    have the focus placed back on the first frame's text field after
    closing the pop-up so that I can enter data and tab out to activate
    the onchange function of such text field. Having a blinking cursor of
    such text field while not really having the focus on such field seems
    confusing to users.

    Thanks very much for every bit of help.

    Dai
     
    Dai Ba Wong, Jun 29, 2004
    #1
    1. Advertising

  2. Dai Ba Wong

    kaeli Guest

    In article <>,
    enlightened us with...
    >
    > My problem is as users click on the link of the second frame, the
    > focus is placed on the selected link and a window pops up. How can I
    > have the focus placed back on the first frame's text field after
    > closing the pop-up so that I can enter data and tab out to activate
    > the onchange function of such text field. Having a blinking cursor of
    > such text field while not really having the focus on such field seems
    > confusing to users.
    >


    Have a global function in the frame that sets a variable to an element
    each time one gets focus. This keeps track of where the user is. In the
    onFocus of the window, set cursor focus to that element. Don't forget to
    test it for null or set to a default for the first load before the user
    has actually focused anything.

    Note that i do not recommend this for internet use. Intranet and CD
    would be fine.

    --
    --
    ~kaeli~
    Going to church doesn't make you a Christian any more than
    standing in a garage makes you a car.
    http://www.ipwebdesign.net/wildAtHeart
    http://www.ipwebdesign.net/kaelisSpace
     
    kaeli, Jun 29, 2004
    #2
    1. Advertising

  3. Dai Ba Wong

    Dai Ba Wong Guest

    kaeli <> wrote in message news:<>...
    > In article <>,
    > enlightened us with...
    > >
    > > My problem is as users click on the link of the second frame, the
    > > focus is placed on the selected link and a window pops up. How can I
    > > have the focus placed back on the first frame's text field after
    > > closing the pop-up so that I can enter data and tab out to activate
    > > the onchange function of such text field. Having a blinking cursor of
    > > such text field while not really having the focus on such field seems
    > > confusing to users.
    > >

    >
    > Have a global function in the frame that sets a variable to an element
    > each time one gets focus. This keeps track of where the user is. In the
    > onFocus of the window, set cursor focus to that element. Don't forget to
    > test it for null or set to a default for the first load before the user
    > has actually focused anything.
    >
    > Note that i do not recommend this for internet use. Intranet and CD
    > would be fine.
    >
    > --


    Thanks Kaeli, but I wonder other than setting a global variable to
    remember the last focused field and automatically set back the focus,
    is there any way for users to click on a link of another frame and
    then after such link brings up a pop-up and close the window, the
    focus can be brought back the original frame. Is there such innate
    Javascript function since somehow the original frame's text field
    continue to have a blinking cursor throughout the process, I wonder if
    there's any function to have the focus stay on the field instead of
    sending the focus to link of the second frame when it is clicked.

    Thanks for all the time and help!
     
    Dai Ba Wong, Jun 30, 2004
    #3
  4. Dai Ba Wong

    kaeli Guest

    In article <>,
    enlightened us with...
    >
    > Thanks Kaeli, but I wonder other than setting a global variable to
    > remember the last focused field and automatically set back the focus,
    > is there any way for users to click on a link of another frame and
    > then after such link brings up a pop-up and close the window, the
    > focus can be brought back the original frame. Is there such innate
    > Javascript function since somehow the original frame's text field
    > continue to have a blinking cursor throughout the process, I wonder if
    > there's any function to have the focus stay on the field instead of
    > sending the focus to link of the second frame when it is clicked.
    >
    > Thanks for all the time and help!
    >


    Okay, if I understand you, you want to focus the frame.
    So, sure, assuming you know the name of the frame you want focused.
    self.parent.frames['framename'].focus();
    should work from any of the frames in the set.
    If you want to do it from the popup, do
    self.opener.parent.frames['framename'].focus();

    Both assume a simple frameset that doesn't have a frameset within a
    frameset type setup. If you have a complex frameset, replace 'parent'
    with 'top'. Warning: using 'top' will break if a foreign frameset puts
    your frames inside it.

    HTH

    --
    --
    ~kaeli~
    A midget fortune teller who escapes from prison is a small
    medium at large.
    http://www.ipwebdesign.net/wildAtHeart
    http://www.ipwebdesign.net/kaelisSpace
     
    kaeli, Jul 6, 2004
    #4
    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. Sven
    Replies:
    2
    Views:
    5,106
    tragomaskhalos
    Nov 30, 2007
  2. So

    HOWTO: Bring that row back into focus ...

    So, May 3, 2005, in forum: ASP .Net Building Controls
    Replies:
    2
    Views:
    131
  3. So

    HOWTO: Bring that row back into focus ...

    So, May 3, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    2
    Views:
    111
  4. So

    HOWTO: Bring that row back into focus ...

    So, May 3, 2005, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    127
  5. Arvin Portlock
    Replies:
    4
    Views:
    283
    Arvin Portlock
    Jul 12, 2004
Loading...

Share This Page