0

I'd like to close the child window when parent window is closed after showing browser's default dialog(Are you sure you want to leave?), but I couldn't find any solution to do it from parent window

why?

  1. we can't capture the leave and cancel buttons on browser's default dialog to close the child window accordingly in beforeunload event
  2. we can't show a custom dialog there.

Reference for what I've tried: When to close the child window when parent window is being closed in Angular

Requirement: Now I'd like to know where we can check in child window(Coffee Script) that if parent(latest Angular) is open, at regular intervals and close the child window accordingly.

So I basically would like to do something like this..

function CloseOnParentClose() {
  if (typeof window.opener != 'undefined' && window.opener != null) {
    if (window.opener.closed) {
      window.close();
    }
  } else {
    window.close();
  }
}
$(window).ready(function() {
  setInterval(CloseOnParentClose, 1000);
});

my child window code is in coffee Script and I'm new to this, I'd like to know **where to put it, it's syntax in coffee Script ** to meet the above requirement.

Thanks in Advance!

Parth Raval
  • 4,097
  • 3
  • 23
  • 36
  • So you need this JS as coffeescript? It should be straightforward enough. Use the docs as reference, and if you get stuck with anything, post the code you have so far here. – caffeinated.tech Jan 27 '23 at 12:06

0 Answers0