2

嗨,请检查下面的代码我正在尝试打开带有名称的标签,然后尝试关闭该标签但无法关闭,否则任何人都可以告诉我们如何关闭从父标签(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> 
4

2 回答 2

0
<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();
}
于 2012-11-02T10:47:19.437 回答
0

这是您尝试做的一个示例... 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>');
于 2012-11-02T10:59:11.290 回答