你好,我再次問我的功能questionAnswer根本不工作,它是假設提示開關命令。我用這個網站尋求幫助。 http://www.w3schools.com/jsref/met_win_prompt.asp功能不能正常工作
var keyword1 = "how are"
var keyword2 = "what are"
var keyword3 = "creator"
var keyword4 = "why"
var keyword5 = "how did"
var keyword6 = "Where were"
var keyword7 = "what do"
var keyword8 = "color"
var keyword9 = "Bye"
var keyword10 = "animal"
var keyword11 = "Hello"
var robotAnswer1 = "Good"
var robotAnswer2 = "I am the new Lego 「Dames」 droid 7.0. I am the newest and most advanced robot in this century!"
var robotAnswer3 = "My creator is James Day, I was programmed by Emanuel 「Kiwi Elefant」 Rotible"
var robotAnswer4 = "I was made to inspire imagination and bring smiles!"
var robotAnswer5 = "I was created with state-of-the-art technology in a lab."
var robotAnswer6 = "In a lab at Lego’s Headquarters"
var robotAnswer7 = "I can talk, move listen, respond and can teach programming to kids"
var robotAnswer8 = "I do not know what you are trying to say"
var robotAnswer9 = "I was made to inspire imagination and bring smiles"
var robotAnswer10 = "I was created with state-of-the-art technology in a lab"
var robotAnswer11 = "In a lab at lego's Headquarters"
function questionAnswer() {
var text;
var questionAnswer = prompt(「Ask me a Question!」);
switch(questionAnswer) {
case questionAnswer :
\t text = "Excellent choice! Whatever you said is good for your soul.";
break;
case keyword1:
\t text = robotAnswer1;
break;
case keyword2:
\t text = robotAnswer2;
break;
case keyword3:
\t text = robotAnswer3;
break;
case keyword4:
\t text = robotAnswer4;
break;
case keyword5:
\t text = robotAnswer5;
break;
case keyword6:
\t text = robotAnswer6;
break;
}
<!DOCTYPE html>
<html>
<head>
< script>
var keyword1 = "how are"
var keyword2 = "what are"
var keyword3 = "creator"
var keyword4 = "why"
var keyword5 = "how did"
var keyword6 = "Where were"
var keyword7 = "what do"
var keyword8 = "color"
var keyword9 = "Bye"
var keyword10 = "animal"
var keyword11 = "Hello"
var robotAnswer1 = "Good"
var robotAnswer2 = "I am the new Lego 「Dames」 droid 7.0. I am the newest and most advanced robot in this century!"
var robotAnswer3 = "My creator is James Day, I was programmed by Emanuel 「Kiwi Elefant」 Rotible"
var robotAnswer4 = "I was made to inspire imagination and bring smiles!"
var robotAnswer5 = "I was created with state-of-the-art technology in a lab."
var robotAnswer6 = "In a lab at Lego’s Headquarters"
var robotAnswer7 = "I can talk, move listen, respond and can teach programming to kids"
var robotAnswer8 = "I do not know what you are trying to say"
var robotAnswer9 = "I was made to inspire imagination and bring smiles"
var robotAnswer10 = "I was created with state-of-the-art technology in a lab"
var robotAnswer11 = "In a lab at lego's Headquarters"
function questionAnswer() {
var text;
var questionAnswer = prompt(「Ask me a Question!」);
switch(questionAnswer) {
case questionAnswer :
\t text = "Excellent choice! Whatever you said is good for your soul.";
break;
case keyword1:
\t text = robotAnswer1;
break;
case keyword2:
\t text = robotAnswer2;
break;
case keyword3:
\t text = robotAnswer3;
break;
case keyword4:
\t text = robotAnswer4;
break;
case keyword5:
\t text = robotAnswer5;
break;
case keyword6:
\t text = robotAnswer6;
break;
}
</head>
<body>
<title> Robot interaction </Title>
<base target="_top">
<img class="irc_mi" style="margin-top: 2px;" src="http://engineering.missouri.edu/wp-content/uploads/Lego-Robot.jpeg" width="304" height="390">
</script>
</form>
</body>
<button onclick ="questionAnswer();">Ask</button>
</script>
<body>
<script>
</body>
</html>
你檢查過控制檯嗎?你的代碼有一個問題:'。 – Rajesh
我認爲你會發現你的問題在於空殼, ...案例:\t text =「凱越...,你有沒有嘗試用devtools進行調試? – MCMXCII
爲什麼在HEAD中有表格? – mplungjan