<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>prompt</title>
<script type="text/javascript">
function rec(){
var score;
score=prompt("你的男生还是女生")
if(score==男)
{
document.write(“你好,帅哥!”);
}
else if(score="女")
{
document.write("你是美女吗");
}
}
else
{
document.write("请输入你的性别")
}
</script>
</head>
<body>
<input type="button" name="botton" onclick="rec()" value="惦记我吧,骚年" />
</body>
</html>
prompt的返回值是布尔类型的,所以score只有真或假,即ture或者flash,不能等于其他的字符
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>prompt</title>
<script type="text/javascript">
function rec()
{
var score;
score = prompt("你的男生还是女生");
if(score>=90)
{
document.write("你好,帅哥!");
}
else if(score>=80)
{
document.write("你是美女吗");
}
else
{
document.write("请输入你的性别");
}
}
</script>
</head>
<body>
<input type="button" name="button" onClick="rec()" value="惦记我吧,骚年" />
</body>
</html>
好像把true写成了ture,啊啊啊,英语好烂啊