Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

retain focus on child page while refreshing parent page

 
Sai Sudha Chaganti
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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.

self.focus();
window.opener.location.reload(true);
self.focus();
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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);

Eric
 
Terry Jeske
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic