<html xmlns=" http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>测试按钮事件</title>
<script language="vbscript">
<!--
sub button_onclick
if document.form.answer.value="1" then call right else call wrong
end sub
sub right
msgbox "嘿嘿,真厉害,你答对了。",64,"脑筋急转弯"
sub wrong
msgbox "答错了,要好好加油哦!",32,"脑筋急转弯"
end sub
-->
</script>
</head>
<body>
<p>问题1.粽子的含义是什么?请选择:<br />
(1)间谍<br />
(2)中国某种民间小食<br />
(3)肥胖者</p>
<form id="form" name="form" method="post" action="">
请输入你的答案:
<label>
<input type="text" name="answer" id="answer" />
</label>
<br />
<label>
<input type="submit" name="button" id="button" value="提交" />
</label>
</form>
</html>
预览错误显示:
<html xmlns=" http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>测试按钮事件</title>
<script language="vbscript">
<!--
sub button_onclick
if document.form.answer.value="1" then
call right
else
call wrong
end if
end sub
sub right
msgbox "嘿嘿,真厉害,你答对了。",64,"脑筋急转弯"
end sub
sub wrong
msgbox "答错了,要好好加油哦!",32,"脑筋急转弯"
end sub
-->
</script>
</head>
<body>
<p>问题1.粽子的含义是什么?请选择:<br />
(1)间谍<br />
(2)中国某种民间小食<br />
(3)肥胖者</p>
<form id="form" name="form" method="post" action="">
请输入你的答案:
<label>
<input type="text" name="answer" id="answer" />
</label>
<br />
<label>
<input type="submit" name="button" id="button" value="提交" />
</label>
</form>
</html>
sub right这个过程没有关闭。。。
在网页中一般不要用vbscript来写脚本,因为vbscript只有IE能支持。
网页脚本一般用javascript来写。