0

I am trying to refresh parent tab that opened a window. In order to do that I am trying to catch close event of the tab so that once I catch the event, I will refresh parent window and this tab will get closed

<script type="text/javascript">
    window.onbeforeunload = function(){
     alert("test");
    };
</script>

Whatever I do, I always get this message. enter image description here

If I comment return "test" I don't get the message, that means the code does something which eventually causes the given alert. How to catch the tab/current window close event in JS or jquery?

PS: Checked solutions on Run JavaScript code on window close or page refresh? and How to capture the browser window close event? , they are not working anymore. Probably, newer versions have something to do with this.

Community
  • 1
  • 1
Danyal Sandeelo
  • 12,196
  • 10
  • 47
  • 78

0 Answers0