[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to maintain focus on Javascript alert?

Posted on 2005-05-13
6
Medium Priority
?
1,343 Views
Last Modified: 2008-06-10
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.
0
Comment
Question by:tawb
  • 3
  • 2
6 Comments
 
LVL 25

Expert Comment

by:archrajan
ID: 13997941
show us some code
0
 

Author Comment

by:tawb
ID: 13997975
I can not.  But can you?
0
 
LVL 9

Expert Comment

by:ftaco96
ID: 13998229
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:tawb
ID: 13998504
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
 
LVL 9

Expert Comment

by:ftaco96
ID: 13998586
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
 
LVL 9

Accepted Solution

by:
ftaco96 earned 2000 total points
ID: 13998649
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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question