Javascript比较提示返回的字符串

时间:2014-11-10 09:40:59

标签: javascript html string compare prompt

您好我是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>

谢谢你的帮助。我知道我的评分可能会下降,但我搜索并且说实话,我不知道为什么这不起作用。我尝试了很多不同的东西。

1 个答案:

答案 0 :(得分:1)

你的错误就在这一行:

windows.confirm("Sorry that is not correct...no money for you.");

windows.confirm("You are CORRECT... 

请将'windows.confirm'更改为'window.confirm'。

相关问题