第2个问题可以使用onKeyUp函数截获
第3个问题可以在使用onKeyUp函数截获回车时候,将该文本框的value属性设为"",然后使用focus函数将焦点聚焦在该文本框。
<input type="text" name="xx" value="">
<script>
function getEnter(){
if(window.event.keyCode==13){
document.all.xx.value="";
document.all.xx.focus();
}
}
</script>
第3个问题可以在使用onKeyUp函数截获回车时候,将该文本框的value属性设为"",然后使用focus函数将焦点聚焦在该文本框。
<input type="text" name="xx" value="">
<script>
function getEnter(){
if(window.event.keyCode==13){
document.all.xx.value="";
document.all.xx.focus();
}
}
</script>
<input type="text" name="xx" value="" Onkeydown="getEnter();">
<script>
function getEnter(){
if(window.event.keyCode==13){
document.all.xx.value="";
document.all.xx.focus();
}
}
</script>
问题全部解决。
但是发现document.all在FireFox里面会报警。
<input type="text" id="xx" name="xx" value="" onkeydown="getEnter(event)">
<script>
function getEnter(e){
e=e||event;
if(e.keyCode==13){
document.getElementById("xx").value="";
document.getElementById("xx").focus();
}
}
</script>