File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes retain focus on child page while refreshing parent page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "retain focus on child page while refreshing parent page" Watch "retain focus on child page while refreshing parent page" New topic

retain focus on child page while refreshing parent page

Sai Sudha Chaganti

Joined: Jul 29, 2004
Posts: 4

I have two jsps, one will be called from another.
On updating some info on the second jsp, the first jsp should be refreshed, but the focus should be retained on the child (2nd) jsp.

Any suggestions on this.

I wrote the following javascript code on the 2nd jsp.It is refreshing the parent(1st) jsp but the focus goes back to the parent jsp.I need the focus to be retained on the child jsp.For some reason self.focus() is not working in this case.

Eric Pascarello

Joined: Nov 08, 2001
Posts: 15385
FYI: refreshing the parent is most likely going to kill the parent child relationship since refreshing tha page destroys the window object that created the pop up window. There is no way to avoid this other then using frames which is ewww (a mess to maintain).

Other then that to answer your question, try using a timeout that fires the code.
var timer = window.setTimeout("window.focus()",500);

Terry Jeske

Joined: Apr 06, 2004
Posts: 17
I have a similar problem, and was wondering if there was an elegant solution.

I process a form in a pop-up window using Ajax. I would like to fire a:

This obviously refreshes the parent window, and then closes the pop-up. In order to get this to work asynchronously, I fire these calls in my ajax_update_resp() callback function. It works in IE, but (shockingly) crashes my beloved Firefox.

If I do:

I am not guaranteed that the opener window will pick up the changes in time. I have thought about a small delay, but ouch -that is exact opposite effect I was looking for by using Ajax.

Any ideas, anyone?
I agree. Here's the link:
subject: retain focus on child page while refreshing parent page
It's not a secret anymore!