Javascript 无法关闭浏览器中打开的其他选项卡

Javascript 无法关闭浏览器中打开的其他选项卡,javascript,html,Javascript,Html,您好,请检查下面的代码,我正在尝试打开名为的选项卡 然后尝试关闭该选项卡,但无法关闭 或者,有人能告诉我们如何在关闭父选项卡时从父选项卡(url)关闭打开的所有选项卡(url1,url2) firebug中的错误是my_窗口未定义 <form name="submitForm1" target="my_window" method="POST" action="http://localhost:8080/ADDMIBREP/"> <input t

您好,请检查下面的代码,我正在尝试打开名为的选项卡 然后尝试关闭该选项卡,但无法关闭 或者,有人能告诉我们如何在关闭父选项卡时从父选项卡(url)关闭打开的所有选项卡(url1,url2) firebug中的错误是my_窗口未定义

 <form name="submitForm1"   target="my_window"  method="POST" action="http://localhost:8080/ADDMIBREP/">
            <input type="hidden" name="uname" value="uname">
            <a HREF="javascript:document.submitForm1.submit();">ADDMIBREPORT</a>
        </form>
        <a HREF="javascript: closepopup() ">remove</a>
    </body>
    <script> 

        function closepopup()
        {
            alert("hi");

            if(false == my_window.closed)
            {
                my_window.close ();
            }
            else
            {
                alert('Window already closed!');
            }
        } <script> 

函数closepopup()
{
警报(“hi”);
if(false==my_window.closed)
{
my_window.close();
}
其他的
{
警报(“窗口已关闭!”);
}
}  

以下是您尝试做的一个示例

var-win=window.open(“,”win“,”宽度=200,高度=100”);
win.document.write(“”);
win.focus();
win.opener.document.write(“这是源代码窗口!

”);
它将关闭当前窗口我想关闭其他窗口我的窗口
<a HREF="javascript:window.close()">remove</a>
var my_first_window = window.open('test/test.html');
var my_second_window = window.open('test/test1.html');

window.onunload = function() {
    if(!my_first_window.closed)
        my_first_window.close();
    if(!my_second_window.closed)
        my_second_window.close();
}
var win = window.open("", "win","width=200,height=100");
win.document.write('<a href="#" id="close" onclick="window.close();">This is myWindow! Click to close</a>');
win.focus();
win.opener.document.write('<p>This is the source window!</p>');