<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>系好安全带,准备启航</title>
<!--引入外部文件的方式-->
<script type="text/javascript">
function go()
{
var zou=confirm("点击");
if (zou==true)
{
document.write("准备好,起航吧");
}
else{
document.write("ssssswandanle ");
}
}
</script>
</head>
<body>
<input type="button" onclick="go" value="点击">
</input>
</body>
</html>
document.write("准备好,起航吧"); document.write("ssssswandanle ");
这2行最后的分号改为英文的分号
document.write("准备好,起航吧"); document.write("ssssswandanle ");
<input type="button" onclick="go" value="点击">
这里调用函数缺了()
<input type="button" onclick="go()" value="点击">
完整代码
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>系好安全带,准备启航</title> <!--引入外部文件的方式--> <script type="text/javascript"> function go() { var zou=confirm("点击"); if (zou==true) { document.write("准备好,起航吧"); } else{ document.write("ssssswandanle "); } } </script> </head> <body> <input type="button" onclick="go()" value="点击"> </input> </body> </html>