嗨,请检查以下代码我正在尝试打开带有名称的标签 之后尝试关闭该选项卡但无法关闭 或者任何人都可以告诉我们如何在关闭父标签时从父标签(网址)关闭打开所有标签(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>
答案 0 :(得分:0)
<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();
}
答案 1 :(得分: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>');