谷歌浏览器不支持功能

时间:2014-03-22 11:18:51

标签: javascript google-chrome

我遇到的问题是,该功能无法在Google Chrome上运行,但在IE上运行成功。我真的需要它在Chrome上运行。

function SubmitForm(){

 if(textbox2.value=="OFFERED RATE"){
    alert(" C o n g r a t u l a t i o n s ! \n You are absolutely CORRECT");
    location.href='list_quiz.html';
}else
alert("Sorry, You are WRONG.\n The correct answer is OFFERED RATE");
    location.href='list_quiz.html';
}
<button onclick="SubmitForm()">Submit New</button>

请帮助解决错误。

谢谢。

1 个答案:

答案 0 :(得分:0)

请改为尝试:

HTML文件

<button id="submit_form">Submit New</button>

JAVASCRIPT FILE

button = document.getElementById('submit_form')
button.addEventListener("click", SubmitForm, false);

然后,您还必须更改SubmitForm()函数以获取textbox2值,如下所示:

answer = document.getElementById('textbox2').value
if (answer=="OFFERED RATE"){
...
}