<script type='text/javascript'>
window.onbeforeunload = function() {
   //in case of a close action with the white cross in the red square in the title bar

   if (window.event.clientY < 0 && (window.event.clientX > (document.documentElement.clientWidth - 5) || window.event.clientX < 15)) {

     //action to fire when leaving...
window.opener.location.reload();
//  alert('user is leaving...');
 }
}
</script>