giving commans to a parent window

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
Charles256
DevNet Resident
Posts: 1375
Joined: Fri Sep 16, 2005 9:06 pm

giving commans to a parent window

Post by Charles256 »

Is there any way that when you open up a new window via javascript and that same window is closed is it possible to send a command back to the the parent window when it closes? i.e. after a page is viewed the status on the main page is going to change, i want to reflect this change as soon as the window is closed.this could be accomplished by simply refreshing the window but i want it dont automatically.make any more sense?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

window.opener is the reference to the parent of the window.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

Code: Select all

<script type='text/javascript'>
window.addEventListener('load', function(e) {
   window.addEventListener('unload', function(e) {
      window.opener.Func();
   }, false);
}, false);
</script>
This is pop-up window. When it's closed (or reloaded) it would run the Func function in the context of its opener
Charles256
DevNet Resident
Posts: 1375
Joined: Fri Sep 16, 2005 9:06 pm

Post by Charles256 »

<body onUnload='window.opener.location.reload(true)'>

tada :-D
Post Reply