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?
- we can't capture the leave and cancel buttons on browser's default dialog to close the child window accordingly in beforeunload event
- 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!