Solved

Detect/address child window on parent reload - IE8 only

Posted on 2012-04-06
8
529 Views
Last Modified: 2012-06-27
I am opening a child window using the code below. From that window, I am reloading the parent document. When the parent document loads, I need to detect if there is the child window and, if so, extract a form element value to set a highlighted row in the reloaded parent document.

How do I reliably detect/address the spawned window on reload? This only needs to work for IE8 in a controlled environment.

*******************************************************************

window.onload = initPage;

function initPage() {

    document.form1.btnAddMedication.onclick = function () {
        var strURL = 'clientmedication_add.aspx?id=<%=clientid%>';
        var w = window.open(strURL, 'addMed', 'width=680,height=850,toolbar=no,location=no,directories=no,status=yes,menubar=no,resizable=yes,copyhistory=yes');
    };

}
0
Comment
Question by:sailing_12
[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
  • 2
  • 2
  • +1
8 Comments
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 500 total points
ID: 37817482
Why not either load the parent with the parameter or call a script in the parent to reload with the parameter or set a cookie before reload???
0
 
LVL 20

Expert Comment

by:Proculopsis
ID: 37818404
A simple solution is to use a hidden master frame to retain the context and coordinate the creation of pop-up windows and reloading of subordinate frames.
0
 
LVL 9

Expert Comment

by:experts1
ID: 37820603
This solution should work for you!

It works with a setinterval loop in the child window
which sends a reminder every 5 seconds to parent window.
And the parent window checks every 5 seconds for the
signal from the child window:

JS code for parent window:
---------------------------
  var child_exist = false;

window.onload = function() {
  childCheck = setInterval ( "check_child()", 5000 );
}
  
function check_child() {
  if(child_exist) {
    alert("child window exists");
    clearInterval(childCheck);
   }
}

Open in new window

JS code for child window:
---------------------------
window.onload = function() {
  setInterval ( "alert_parent ( )", 5000 );
}

function alert_parent ( ) {
  if(window.opener) window.opener.child_exist = true;
}

Open in new window

0
Technology Partners: 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!

 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 37820625
experts1

1) window.opener will likely disappear on reload

2) please code your future setIntervals and setTimeouts like this
setInterval(alert_parent, 5000 );
since using quotes is an impliit eval.


sailing_12

To get the handle of a window opened by name, open it again;

First time:

window.open("someUrlOntheSameServer","childWindow1");

second time

var childWindow = window.open("","childWindow1");
var someField = childWindow.document.forms[0].myField.value;

but I recommend cookies
0
 
LVL 9

Expert Comment

by:experts1
ID: 37820692
Hi  mplungjan!

Been like years I havent got a feedback from you.

Thanks for the reminder.

Cheers
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 37820729
I never left ;) just hit 10mio points a few weeks ago
0
 

Author Comment

by:sailing_12
ID: 37823252
Thanks for all the feedback. I am currently working the cookie approach to see if it meets my needs.
0
 

Author Closing Comment

by:sailing_12
ID: 37883433
Cookie approach seems to work for me. Thanks.
0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Suggested Solutions

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

739 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