admin管理员组

文章数量:1410737

There is a page in asp which have a link that opens into a new tab in browser. So when I close my parent tab all the child tabs should be closed.

How can I do that?

My approach was using Javascript but till now not reached too far.

There is a page in asp which have a link that opens into a new tab in browser. So when I close my parent tab all the child tabs should be closed.

How can I do that?

My approach was using Javascript but till now not reached too far.

Share Improve this question edited Jul 30, 2021 at 8:22 Brian Tompsett - 汤莱恩 5,89372 gold badges61 silver badges133 bronze badges asked Jul 28, 2011 at 11:56 ankurankur 4,74315 gold badges67 silver badges104 bronze badges 1
  • @ -1 marker can u provide the reason for your curtsy – ankur Commented Jul 28, 2011 at 12:20
Add a ment  | 

1 Answer 1

Reset to default 6

Whenever you call window.open(), you are given a handle:

myWindow = window.open(/* open stuff*/);

If you keep track of these handles in an array (for example), you can then call:

myWindow.close();

When you're done.

Edit

For example:

var wnds = new Array();

Whenever you want to open a window:

wnds[wnds.length] = window.open(/* open stuff*/);

And to close them all

for(i = 0; i < wnds.length; ++i)
    wnds[i].close();

本文标签: javascriptClose all child tabs when parent tab is closedStack Overflow