473,385 Members | 1,645 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How do you Notify Parent window after finished with Child?

Frinavale
9,735 Expert Mod 8TB
I've seen this question being asked over and over again and don't know the answer.

Situation:
There's a web browser displaying a list off stuff.
There's a button that lets the end user add a new thing to the list of stuff.
A new web browser is opened to let the end user enter the information about the thing.

Question:
Is there a way to notify the Parent window when the user's finished entering information about the thing so that they can update the list of stuff?

Thanks for any pointers on how to achieve this.

-Frinny
Jan 6 '09 #1
9 4324
acoder
16,027 Expert Mod 8TB
You could use a button where onclick you could refer to the parent using window.opener. You could also avoid popup windows by using DHTML.
Jan 6 '09 #2
Frinavale
9,735 Expert Mod 8TB
@acoder
I'll look into window.opener thanks.

@acoder
This is usually what I recommend because it just makes so much more sense in the long run...today I felt like giving people the answer they're actually looking for :)
Jan 6 '09 #3
Frinavale
9,735 Expert Mod 8TB
Window.opener works like a dream :)

Thanks again!
Jan 6 '09 #4
acoder
16,027 Expert Mod 8TB
You're welcome :) @Frinavale
I know what you mean. It's a bit like when a client insists on something that's not quite best practice.
Jan 6 '09 #5
Frinavale
9,735 Expert Mod 8TB
There doesn't appear to be a window close event...

Is there a way for the parent to be able to tell when the child window is closed?

Or is there some event, other than a button click, that is fired when a window is closed...so that the parent can be notified?
Mar 10 '09 #6
acoder
16,027 Expert Mod 8TB
You can use the window.closed property.

When a window is closed, on(before)unload should fire, but it also fires when moving/refreshing.
Mar 10 '09 #7
Frinavale
9,735 Expert Mod 8TB
The fact that it's fired when the window is moving is not good.
I tried setting:

Expand|Select|Wrap|Line Numbers
  1. window.onbeforeunload = myFunctionThatNotifiesTheParentWindow;
However when I clicked the close button in the child window, the parent window was not notified.

<edit>Right, sometimes I'm an idiot, I placed that code in the parent window, not the child! No wonder it wasn't working >>blush<< I wonder if the other stuff I was trying would have worked had it have been placed in the child window...</edit>
Mar 10 '09 #8
acoder
16,027 Expert Mod 8TB
Sorry, by moving, I meant moving back and forward in the browser history or simply visiting a link. Note that this doesn't happen in Opera, though.

How are you trying to notify the parent window? Do you call a function in the parent?
Mar 10 '09 #9
Frinavale
9,735 Expert Mod 8TB
@acoder
That makes more sense....I tried moving the window and wondered why the closed event didn't fire when I moved it..........hehe

@acoder
Yes, I have a function in the parent that is called by the child.

Parent Page (onload the window parent window is given a name):
Expand|Select|Wrap|Line Numbers
  1. function DoStuff() {
  2.     //Does some stuff
  3.  }
Client Page:
Expand|Select|Wrap|Line Numbers
  1. window.onbeforeunload = CloseEvent;
  2.  
  3. function CloseEvent() {
  4.    if (window.opener && !window.opener.closed) {
  5.       window.opener.DoStuff();
  6.    }
  7. }
It's pretty simple actually...the reason it wasn't working before was because I had placed the window.onbeforeunload code in the wrong place.
Mar 10 '09 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Joe D | last post by:
I think this is a simple question. But I am new to JS. Here is what I want to do: From a parent window, open a popup window (child) to get data from user, then user submit the request, close the...
9
by: Randell D. | last post by:
Folks, I'm working on a contact name/address database whereby a slimed down list is shown in the main window. When a record is selected, the complete record is displayed in a new window via a...
2
by: Bostonasian | last post by:
I am trying to append options to dropdown in parent window from option items in child window. In parent window, I have following code: <script language="javascript"> function...
4
by: Davey | last post by:
I have a website which has a popup window (this only opens when the user chooses to open it). In the popup window I have a <select> control which lists a selection of "classes". Each class has a...
2
by: Raj | last post by:
Hi All, I have a problem with trying to refresh the parent window from child window in order to update data in the parent window. The sequence of events are 1) I click a button in the parent...
1
by: Earl Teigrob | last post by:
I did a ton of searching to try and find a simple solution to this issue and finally wrote my own, which I am sharing with everyone. In my searching, I did find a very complete and robust solution at...
1
by: Bill Borg | last post by:
Hello all, Simple chat app, where the site owner has a master window with all requests for chat, status of each room, etc., and child windows for each separate chat in which the owner is...
1
by: ace danger | last post by:
I have some javascript that works in Firefox 2 but not in IE 7. In the parent page, a user clicks a link and a new window is opened so that they can maintain some values. When the user is...
4
by: Buddha | last post by:
Hello, I posted this on two forums, without too much help .. and I am kinda stuck in this. I need to refresh the parent page from the second child window which is opened by the first child and...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.