问题
1.按"在新窗口中累加"有时会报错,大概是新窗口还未装载好,无法识别aWin.txt
2.在按"新窗口"时,如何将先前的新窗口覆盖,我先检测新窗口aWin是否已经打开,如果打开则先关闭;然后用的是open里的_blank但是不行,后来改成_media就行了,但在ie下好象不认.
以下是代码,望高手帮下小弟
<html> //test.php
<head>
</head>
<script language="javascript">
var aaa=1;
var aWin=1;
function nwindow()
{if(aWin.open)
aWin.close;
aWin=window.open("information1.php","_media","top=0,left=0,width=200,height=200,toolbar=no");
aWin.focus();
}
function opentwo()
{document.all.first.disabled=false;
document.all.second.disabled=false;
document.all.ynnew.disabled=true;
}
function nouse()
{document.all.first.disabled=true;
document.all.second.disabled=true;
}
function addone()
{if(aWin.open)
aWin.close;
aWin=window.open("information2.php","_media","top=0,left=0,width=200,height=200,toolbar=no");
aWin.focus();
aWin.txt1.value=aaa;
aaa=aaa+1;
}
function winclose()
{aWin.close();
document.all.first.disabled=true;
document.all.second.disabled=true;
document.all.ynnew.disabled=false;}
</script>
<INPUT TYPE="button" ID=nwin VALUE="新窗口" onClick="nwindow()">
<INPUT TYPE="button" name=ynnew value="打开后面2个" onClick="opentwo()">
<INPUT TYPE="button" name=first value="在新窗口中累加" onClick="addone()">
<INPUT TYPE="button" name=second value="关闭新窗口" onClick="winclose()"> <br>
<body onload="nouse()">
</body>
</html>
<script language="javascript"> //information1.php
window.setTimeout("window.close()",10000);
</script>
<body>
<center><h3>通知</h3></center>
10秒中后,这个窗口自动关闭!
<center><input type="button" value="关闭" onCLICK="window.close()"></center>
</body>
<body> //informtion2.php
<center><h3>通知</h3></center>
<br>
<script language="javascript">
</script>
你已经点击"在新窗口中累加"按钮<input type="text" value="1" id=txt1 style="width:20px;height:20px"> 次了!!!
<center><input type="button" value="关闭" onCLICK="window.close()"></center>
</body>