问一个js问题. 按enter提交表单是默认的,都这样的应该. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title>无标题页</title></head><body onkeydown="bodyKeyDown(event)" onload="focusInput()"> <form id="form1" runat="server"> <div> <input type="text" id="txt1" /> </div> </form></body></html><script type="text/javascript"> function bodyKeyDown(e) { var kc=e.keyCode; if(kc==32) { focusInput(); } else if(kc==13) { document.form1.submit(); } } function focusInput() { document.getElementById('txt1').select(); document.getElementById('txt1').focus(); } </script> 谢谢avon520了,但是按下空格键时候老是有空格出现,怎样让不出现空格啊. 就是说按space后txt有个空格键,怎样不要出现啊. 你 按下空格后, 把你的事件 执行过后,再 把txt的空格截取掉就行了 function focusInput() { document.getElementById('txt').select(); document.getElementById('txt').focus(); document.getElementById('txt').value=''; }这样不行啊..... 变量问题 请教一个javascript关于生成随机数的问题 又迷茫了,不知如何是好,大家是否也遇到过同样的问题呢? 高手帮忙解决下javascript问题 js对象修改的问题 帮帮忙,javascript如何传值给php变量 我这样写为什么错了? 如果在一个Iframe中的页面调用父页面的对象?求教! 哪里有Javascript的chm函数手册?40分相送 这代码是什么意思,主要是我没见过这种。。。。 这段代码为何运行不了?调用时说缺少对象 动态加入URL参数
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>无标题页</title>
</head>
<body onkeydown="bodyKeyDown(event)" onload="focusInput()">
<form id="form1" runat="server">
<div>
<input type="text" id="txt1" />
</div>
</form>
</body>
</html>
<script type="text/javascript"> function bodyKeyDown(e)
{
var kc=e.keyCode;
if(kc==32)
{
focusInput();
}
else if(kc==13)
{
document.form1.submit();
}
}
function focusInput()
{
document.getElementById('txt1').select();
document.getElementById('txt1').focus();
}
</script>
{
document.getElementById('txt').select();
document.getElementById('txt').focus();
document.getElementById('txt').value='';
}
这样不行啊.....