<html>
<head>
<title>测试window对象</title>
<script type="text/javascript">
function checkWin()
{
if(myWindow.closed)
{
document.write("closed")
}
else
{
document.write("opened")
}
}
</script>
</head>
<body >
<script type="text/javascript">
myWindow=window.open('','','width=200,height=100');//就是这里,我想在myWindow=前加上var 如var myWindow= ,就会出错,应该如何写呢??
myWindow.document.write("This is 'myWindow'");//window.open产生是什么东西呢??如何定义它呢
</script>
<input type="button" value="点击出现窗口" onclick="checkWin()"/>
</body>
</html>
上面的代码是好的,只是我想学透一些。就在myWindow=window.open前加了var myWindow=window.open,所以出了错,想问js的朋友,myWindow前加什么呢能不出错。
答对了立即给分的
------解决方案--------------------------------------------------------
- HTML code
<html > <head > <title >测试window对象 </title > <script type="text/javascript"> function checkWin() { if(myWindow.closed) { document.write("closed") } else { document.write("opened") } } </script > </head > <body > <script type="text/javascript" > var myWindow=window.open( ' ', ' ', 'width=200,height=100 '); myWindow.document.write("This is 'myWindow '");</script > <input type="button" value="点击出现窗口" onClick="checkWin()"/ > </body > </html >