求助:JavaScript open()和close()的问题

来源:百度知道 编辑:UC知道 时间:2024/05/27 08:21:27
<script>
var mywindow=window.open("index.htm");
</script>

<form name="form1" method="post" action="">
<input type="button" name="Submit" value="打开" onclick="mywindow.open()">
<input type="button" name="Submit2" value="关闭" onclick="mywindow.close()">
</form>

程序运行后,为何不能打开窗口和关闭窗口?请高手帮忙解决.

应改为:
<html>
<script language="javascript">
function mywindowOpen(){
window.open("index.html");
}
function mywindowClose(){
window.close();
}
<script>

<form name="form1" method="post" action="">
<input type="button" name="Submit" value="打开" onclick="mywindowOpen()">
<input type="button" name="Submit2" value="关闭" onclick="mywindowClose()">
</form>
<html>