简体   繁体   English

无法关闭浏览器中其他打开的标签页

[英]not able to close other opened tab in browser

hi please check the below code i am trying to open tab with name and after that try to close that tab but unable to close or else can anyone tell how we can close opened all tab (url1,url2) from parent tab (url) while close parent tab error in firebug is my_window is undefined 您好,请检查下面的代码,我试图用名称打开选项卡,然后尝试关闭该选项卡,但无法关闭,否则任何人都可以告诉我们如何从父选项卡(url)关闭所有已打开的选项卡(url1,url2)在firebug中关闭父选项卡错误是my_window未定义

 <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> 
<a HREF="javascript:window.close()">remove</a>

OR 要么

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

Heres an example of what your trying to do... http://jsfiddle.net/KjBj3/7/ 以下是您尝试执行的操作的示例... http://jsfiddle.net/KjBj3/7/

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>');

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

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