如何转移焦点?
一个表单,我输入几个数据(如框A,框B)后,马上要求焦点转移到一个按钮(BUTTON C,该按钮不是sumbit)上,如如何实现?
请高手相助,谢谢!
问题点数:32、回复次数:3Top
1 楼BrentIvan(Ivan)回复于 2001-05-29 08:48:00 得分 25
<script language="JavaScript">
function handleKey() {
if (window.event.keyCode == 27) {
window.close();
}
if (window.event.keyCode == 13) {
if (window.event.srcElement.name == "text1") {
document.formname.text2.focus();
}
if (window.event.srcElement.name == "text2") {
document.formname.text3.focus();
}
if (window.event.srcElement.name == "text3") {
document.formname.text4.focus();
}
if (window.event.srcElement.name == "text4") {
document.formname.button1.focus();
}
window.event.returnValue = false;
}
}
</script>
<body onkeypress="handleKey()" onload="document.formname.text1.focus()">
<form name="formname">
<input type="text" name="text1"><br>
<input type="text" name="text2"><br>
<input type="text" name="text3"><br>
<input type="text" name="text4"><br>
<input type="button" name="button1">
</form>
敲回车键试试
</body> Top
2 楼0007(0007)回复于 2001-05-29 09:54:00 得分 7
就象上面的试试Top
3 楼tiangou(simple)回复于 2001-05-29 10:56:00 得分 0
Thank you very much!
Another question:How to transfer the focus to a href .(<a href=""></a>),other than a button?Top




