Sunday, December 15, 2013

refresh parent window while closing child popup window using javascript


parent script:
===========
win = window.open(mypage,myname,settings);

in child window code:
 ==============
window.onunload = function() {              
    window.opener.location.reload();
};

or

window.onbeforeunload  = function() {               
  window.opener.location.reload(); 
};

Difference between onunload and onbeforeunload is

using window.onunload , able to get an event called when user navigates to a different page from onepage to another . However nothing happens when the tab is closed from the minimized view (X)

Using window.onbeforeunload, I neither get an an event called even if the user navigates to a different page from onepage to another OR if he closes the tab (X) from the minimized view.