1

I am working on a web application and there is some requirement to open child tab. So, when someone close parent tab all child tab should be close.

I have done this requirement but when I refresh my parent tab that time all child are also close. How will I prevent or restrict to child page are not close after parent page refresh?

Code

var allOpenPage=[];
$('#Anchor1').click(function(){
    allOpenPage[0] = window.open('http://google.com', '_blank');
});
$('#Anchor2').click(function(){
    allOpenPage[1] = window.open('http://bing.com', '_blank');
});
$('#Anchor3').click(function(){
    allOpenPage[2] = window.open('http://yahoo.com', '_blank');
});

Parent Page Close Event

window.addEventListener("beforeunload", function (e) {
  for(var j=0;j<allOpenPage.length;j++){
   allOpenPage[j].close();
  }
});
ANJYR
  • 2,583
  • 6
  • 39
  • 60

0 Answers0