?
Solved

Refresh parent window from child window while retaining focus on child window

Posted on 2009-05-13
5
Medium Priority
?
1,948 Views
Last Modified: 2013-11-19
The issue I'm facing is as follows:
1. I have a browser window - say Window A - open.
2. On clicking a link this window opens a popup window.
3. After opening the popup I need to refresh the parent page (which has a pointer to the child popup window).
4. After refreshing the parent page I want to give the focus back to the child page. But since I refreshed the parent page, I no longer have a pointer to the child window.

Is there any way I can get around this problem.
0
Comment
Question by:Seeker2468
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 1

Assisted Solution

by:ckontz
ckontz earned 80 total points
ID: 24382099
The child can ask the parent to refresh and the child will still have reference to itself.  Reloading the parent doesn't change focus to it.  If there is code in the parent that gives it focus, then call it after you reload the parent() - maybe after a short delay for the reload to finish).

The following function can be called multiple times from the child window:

function refreshParent()
{
  window.opener.location.reload(true);
  // if the parent sets focus to itself, then add the next line
  setTimeout('focus();',5000);  // gives focus back to this window after 5 seconds
}
0
 

Author Comment

by:Seeker2468
ID: 24386002
This sounds good, but there is a twist to the story :) I can't change code on the child popup I am calling. Its sort of in a different module so to speak, and is called by other pages which dont require the behavior that my parent page requires - i.e. to refresh itself.

So the only option for me is to launch the child, refresh myself, and then somehow set the focus to the child window. I'm not quite familiar with javascript, so not sure how possible this is.
0
 

Author Comment

by:Seeker2468
ID: 24386036
More specifically if I retain the name of the child window, is there a way when the page refreshes itself to find all child windows with a particular name? Something along these lines.
0
 
LVL 12

Assisted Solution

by:Chad Haney
Chad Haney earned 120 total points
ID: 24399765
Try using something like this.

Because of the way the javascript calls are made it will open the child, then the child will end up calling the parent part of the script due to the focus change.
<a href="javascript:window.open('http://www.google.com','childWindow');parent.window.location.reload();">link</a>

Open in new window

0
 

Accepted Solution

by:
Seeker2468 earned 0 total points
ID: 24403902
dachusa, I havent tried this code. will try and see if it does the job; though I think I'd still have the issue of child window loosing focus, at least in IE (step 4 in the problem).

Just FYI, I did solve my problem another way. I opened the popup as follows

window.open("http://...","popupname",features);
document.theForm.linkName.value = "http://...";//linkName is a request parameter
reload();

onload()=function { window.open(document.theForm.linkName.value,"popupname");}
//This code essentially gives focus back to the already open child window once the parent window is reloaded.
0

Featured Post

Create CentOS 7 Newton Packstack Running Keystone

A bug was filed against RDO for the installation of Keystone v3. This guide is designed to walk you through the configuration for using Keystone v3 with Packstack. You will accomplish this using various repos and the Answers file.

Question has a verified solution.

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

Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
CTAs encourage people to do something specific to show interest in your company, product or service. Keep reading to learn why CTAs should always be thought of as extremely important, albeit small, sections of websites.
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
Suggested Courses

764 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