Link to home
Start Free TrialLog in
Avatar of tawb
tawbFlag for Canada

asked on

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.
Avatar of archrajan
archrajan

show us some code
Avatar of tawb

ASKER

I can not.  But can you?
Are you using showModalDialog()? Could you use showModelessDialog() instead? Do you still need the modal dialog to be open after you change app_field1?
Avatar of tawb

ASKER

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...
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()
}
ASKER CERTIFIED SOLUTION
Avatar of ftaco96
ftaco96

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial