JS Alert Causing Loss Of Window Focus???

Discussion in 'Javascript' started by Robert Nurse, Nov 5, 2004.

  1. Robert Nurse

    Robert Nurse Guest

    Hi All,

    I've got a strange problem in IE that I wonder if anyone has seen
    before. Basically, I've got a two window scenario. The parent window
    opens the child via window.open(). The child contains a form and
    submissions are processed in the child window. When the child window
    form is submitted and the results are returned, an alert box is thrown
    up via setTimeout("alert(....)", 2000). For some odd reason, when
    this alert is displayed, focus is transferred back to the parent
    window with the alert box on top. When you press the OK button on the
    alert, focus is transferred back to where it should be; on the child
    window. This doesn't happen all the time. But it happens. Is there
    something I can do to solve this mystery?

    Thanks.
     
    Robert Nurse, Nov 5, 2004
    #1
    1. Advertising

  2. Robert Nurse

    Robert Guest

    (Robert Nurse) wrote in message news:<>...
    > Hi All,
    >
    > I've got a strange problem in IE that I wonder if anyone has seen
    > before. Basically, I've got a two window scenario. The parent window
    > opens the child via window.open(). The child contains a form and
    > submissions are processed in the child window. When the child window
    > form is submitted and the results are returned, an alert box is thrown
    > up via setTimeout("alert(....)", 2000).


    I'd expect this if the alert was coming from the parent window.


    > For some odd reason, when
    > this alert is displayed, focus is transferred back to the parent
    > window with the alert box on top. When you press the OK button on the
    > alert, focus is transferred back to where it should be; on the child
    > window. This doesn't happen all the time. But it happens. Is there
    > something I can do to solve this mystery?


    Why don't you eliminate the alert and unhide some text in the window
    you want a message to appear?
    >
    > Thanks.


    Robert+
     
    Robert, Nov 5, 2004
    #2
    1. Advertising

  3. Robert Nurse

    Robert Nurse Guest

    Hi,

    I found the problem. When you submit the form on the child, the
    parent was getting refreshed. During this refresh, JS on the parent
    was running: trying to place focus on an edit control. Therefore,
    focus got transferred to the parent window as well. I took care of
    this.



    (Robert) wrote in message news:<>...
    > (Robert Nurse) wrote in message news:<>...
    > > Hi All,
    > >
    > > I've got a strange problem in IE that I wonder if anyone has seen
    > > before. Basically, I've got a two window scenario. The parent window
    > > opens the child via window.open(). The child contains a form and
    > > submissions are processed in the child window. When the child window
    > > form is submitted and the results are returned, an alert box is thrown
    > > up via setTimeout("alert(....)", 2000).

    >
    > I'd expect this if the alert was coming from the parent window.
    >
    >
    > > For some odd reason, when
    > > this alert is displayed, focus is transferred back to the parent
    > > window with the alert box on top. When you press the OK button on the
    > > alert, focus is transferred back to where it should be; on the child
    > > window. This doesn't happen all the time. But it happens. Is there
    > > something I can do to solve this mystery?

    >
    > Why don't you eliminate the alert and unhide some text in the window
    > you want a message to appear?
    > >
    > > Thanks.

    >
    > Robert+
     
    Robert Nurse, Nov 8, 2004
    #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. Replies:
    0
    Views:
    336
  2. Replies:
    0
    Views:
    403
  3. Ganesh
    Replies:
    0
    Views:
    570
    Ganesh
    Jun 29, 2007
  4. Barry Svee

    Using onblur to detect loss of window focus

    Barry Svee, Dec 31, 2003, in forum: Javascript
    Replies:
    1
    Views:
    246
    Thomas 'PointedEars' Lahn
    Jan 11, 2004
  5. Roger
    Replies:
    3
    Views:
    359
Loading...

Share This Page