该代码应该将用户带到一个网站,但我不知道如何将变量放入 if 语句中。例如,在他们输入“Can you go to http://www.google.com ”后,它会转到 Google,如果他们输入“Can you go to http://www.yahoo.com ”,它会去雅虎
<script type="text/javascript">
var question=prompt ("Type in a question");
if (question==("Can you go to " /*a website*/ )){
window.location.href = /*the website that the person typed in after to*/;
}
}
</script>