我有一个小脚本,当在文本框中按下返回时,它会重定向到另一个页面,它在 IE、Chrome、Safari 中运行良好,但在 FireFox 中却不行。如果我在 FireBug 中附加调试器,它就可以工作。
这是我的脚本:
<form name="form1" method="post" action="Default2.aspx" id="form1">
<input id="ind" onkeydown="defaultButton(event)" />
<script type="text/javascript">
function defaultButton(event) {
if (event.keyCode == 13) {
event.returnValue = false;
event.cancel = true;
Send();
}
}
function Send() {
var content = document.getElementById("ind").value;
if (content == null || content.length == 0) {
document.getElementById("ind").focus();
return;
} else {
window.location = "http://www.google.com?name=" + content;
}
}
</script>
有没有人可以帮助我获得这个工作的跨浏览器?非常感谢提前!!