Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Detect/address child window on parent reload - IE8 only

Posted on 2012-04-06
8
Medium Priority
?
531 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 2000 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
Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

 
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

Understanding Linux Permissions

Linux for beginners: How to view the permissions associated with files and directories and also how you can change them.

Question has a verified solution.

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

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

721 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