Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

focusing pre-existing window

Status
Not open for further replies.

jdulberg

Technical User
Jun 19, 2001
22
CA
I'm having some window focusing problems... here's the steps that I've taken:

I am opening a "contact window" from the parent -

Code:
function openFeedbackWindow(thePage) {
   feedbackWin=window.open(thePage,'feedback',settings)
}

From that window, the opened file checks to see if the user has entered a contact signature. If not, user clicks link in child window to open signature editor in parent -

Code:
function openparent(url) {
   opener.location.href = url;
}

Once the user submits new signature in parent, "feedbackWin" is supposed to focus -

Code:
var feedbackWin;

if ( typeof feedbackWin == 'object' ) {
   feedbackWin.focus();
}
else {
   feedbackWin = window.open('/<?=$url;?>','feedback', settings);
}

So that is how I'd like it to be working however instead of feedbackWin focusing the old window with existing contents, the old window is focused and reloaded. So somehow, the feedbackWin variable is being lost in the process.

Does my description make any sense?? It seems like there is just a communication issue between parent and child windows.

Any suggestions for getting around this problem are greatly appreciated!!

Jason
 
When the location of the parent window changes, the link to the child window is lost. To work around this, name the parent window something (not a reserved word) before you launch the contact window, :
window.name='zzmainzz';

In the contact window use:
window.open('javascript:window.focus()','zzmainzz') Adam
 
hmmm... I'm not sure if I explained it properly. The child window should the focusing rather than the parent window. The parent window is already in focus at the time. When the form is submitted from the parent, on success, the child should then focus.

Thanks for your input.

Jason
 
OK, so if adam0101 is correct, and the link to the child window is lost, you have to get it back. You already know the name of the child window, so in the parent window, do:

Code:
var feedbackwin = window.open('','feedback');
feedbackwin.focus();
 
Sweeet... that got it working!

thanks to you both :)

Jason
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top