How to maintain focus on Javascript alert?

In my application, I have a field called "app_field1" with a button next to it called "Find/Choose Item".  When this button is clicked it  launches a javascript modal dialog which lists all possible names from which I can choose from.  I choose an option and hit the 'submit' on this dialog which populates the "app_field1" whose onChange handler gets triggered.  As part of the onChange method I popup an alert to prompt the user that based on this name chosen, other fields in the GUI will be modified.

For some reason, when this alert comes up, it is hidden behind the "Find/Choose Item" dialog window, which will only disappear when the onChange of "app_field1" is completed and hence once the hidden alert window is OK'ed.

How do I maintain the focus on the alert window?

Thanks.
tawbAsked:
Who is Participating?
 
ftaco96Connect With a Mentor Commented:
This will kind of create a new thread, so to speak, for your onchange logic, while letting the onchange event finish. If you need to do some things before the dialog closes, then section the onchange logic into before and after sections and do setTimeout() after the before section, like this:

function onchange() {
    //before logic

    // waits 1 ms
    window.setTimeout("yourNewFunction()" ,1)
}

function yourNewFunction() {
    // after logic
}
0
 
archrajanCommented:
show us some code
0
 
tawbAuthor Commented:
I can not.  But can you?
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

 
ftaco96Commented:
Are you using showModalDialog()? Could you use showModelessDialog() instead? Do you still need the modal dialog to be open after you change app_field1?
0
 
tawbAuthor Commented:
Unfortunately, the code that launches the modal dialog is java-based and belongs to a 3rd party package, i.e. I do not have access to the source code.  

No, the dialog does not need to remain opened once app_field1 has been populated.  That's just the behaviour now, it waits until the field's onChange is complete before disappearing...
0
 
ftaco96Commented:
move everything from the onchange function into a different function and use setTimeout(), like this:

function onchange() {
    // waits 1 ms and runs same code
    window.setTimeout("yourNewFunction()" ,1)
}

function yourNewFunction() {
    // the stuff you had in the original onchange()
}
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.