开发者

Close all child tabs when parent tab is closed

开发者 https://www.devze.com 2023-03-23 18:16 出处:网络
There is a page in asp.net 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.

There is a page in asp.net 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.


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();
0

精彩评论

暂无评论...
验证码 换一张
取 消