window.confirm

来源:百度知道 编辑:UC知道 时间:2024/04/30 14:40:39
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>关闭窗口的确认</title>
<script language="VBScript">
sub btn1_onclick
dim ques
ques=window.confirm("确实要关闭本窗口吗?")
if ques then window.close end if
end sub
</script>
</head>
<body>
<h3 align="center">关闭窗口的确认</h3>
<input type="button" id="btn1" value="关闭窗口">
</body>
</html>
上面的代码错在哪里啦?怎么运行后按关闭窗口按钮没有反应?请各位大侠帮忙!!

把if then end if写在多行上就可以了,下面的程序在我的IE6上运行通过,没有问题:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>关闭窗口的确认</title>
<script language="VBScript">
sub btn1_onclick
dim ques
ques=window.confirm("确实要关闭本窗口吗?")
if ques then
window.close
end if
end sub
</script>
</head>
<body>
<h3 align="center">关闭窗口的确认</h3>
<input type="button" id="btn1" value="关闭窗口">
</body>
</html>