简体   繁体   English

如何关闭所有打开的窗口(父除外)从javascript中的父窗口中单击?

[英]how to close all the opened windows(except the parent)onclick from a parent window in javascript?

I have a parent window which calls for a function that opens 2 new windows in javascript. 我有一个父窗口,它需要一个函数来在javascript中打开2个新窗口。 When I click a close button, I want to close both the child windows. 当我单击关闭按钮时,我想关闭两个子窗口。 I tried window.close(windowname); 我尝试了window.close(windowname); windowName.close(). windowName.close()。 Both didn't work. 两者都不起作用。

Please help.. 请帮忙..

Assign the return values of your window.open(...) calls and call .close() on them later. 分配window.open(...)调用的返回值,然后在它们上调用.close()

Demo: http://jsfiddle.net/ThiefMaster/NCzvH/1/ 演示: http : //jsfiddle.net/ThiefMaster/NCzvH/1/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM