简体   繁体   中英

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

 <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/

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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