【发布时间】:2014-11-10 09:40:59
【问题描述】:
您好,我是 javascript 新手,我已经尝试了一个小时,但老实说,我不知道为什么这不起作用。我继续搜索网站,看起来它应该可以工作。我正在检查存储在 x 中的提示返回的答案是否等于“Al Bundy”。我打印出 x 值,我知道它会返回用户输入的值,但我没有运气进行此比较。
<!DOCTYPE html>
<html>
<head>
<script>
var x;
var check;
function Question()
{
x = window.prompt("In the hit show Married with Children who scored 4 touchdowns in 1 game at polk high?");
if(x == 'Al Bundy')
{
windows.confirm("You are CORRECT!\n\nNow Just confirm to be redirected to our agents.");
}
else
{
windows.confirm("Sorry that is not correct...no money for you.");
}
}
</script>
</head>
<body onload = "Question()">
<script>
window.alert("You have been selected to answer a question for\n\n50 MILLION DOLLARS");
</script>
</body>
</html>
感谢您的帮助。我知道我的评分可能会下降,但我搜索过,老实说,我不知道为什么这不起作用。我尝试了很多不同的方法。
【问题讨论】:
-
你打错了,
windows.confirm而不是window.confirm(或只是confirm)。修复它然后尝试
标签: javascript html string compare prompt