所以我正在为历史课制作一个模拟版的谷歌审查。我试图让搜索在按 Enter 后工作,但到目前为止,我得到的只是搜索我输入的第一个字母。有什么建议么?
HTML 代码:
<form id="searchBox">
<input type="text" id = "search" name="search" size="85" onKeyUp="searchCensor()"/><br />
</form>
JavaScript 代码:
function searchCensor()
{
var keyTerms = document.getElementById("search").value;
if(keyTerms == "censorship")
window.location = "http://andrewgu12.kodingen.com/history/censor.php";
else if(window.event.keyCode == 13)
window.location = "https://www.google.com/search?q="+keyTerms;
else
window.location = "https://www.google.com/search?q="+keyTerms;
}